AE chỉ giúp mình lỗi như này là sửa ở đâu


private void buttonEncrypt_Click(object sender, EventArgs e)
{
string password = textBoxKey.Text;
string salt = textBoxSalt.Text;
string plainText = textBoxInput.Text;
byte[]plainBytes=Encoding.ASCII.GetBytes(plainText);

//Rfc2898DeriveBytes: Used to Generate Strong Keys
//báo lỗi ở dòng bôi đậm này
Rfc2898DeriveBytes rfc = new Rfc2898DeriveBytes(password,
Encoding.ASCII.GetBytes(salt));
//Non-English Alfhabets Will not Work on ASCII Encoding

SymmetricAlgorithm Alg = GetSelectedAlgorithm();

Alg.Key = rfc.GetBytes(Alg.KeySize / 8);
Alg.IV = rfc.GetBytes(Alg.BlockSize / 8);

MemoryStream strCiphered = new MemoryStream();//To Store Encrypted Data

CryptoStream strCrypto = new CryptoStream(strCiphered,
Alg.CreateEncryptor(), CryptoStreamMode.Write);

strCrypto.Write(plainBytes, 0, plainBytes.Length);
strCrypto.Close();
textBoxCiphered.Text = Convert.ToBase64String(strCiphered.ToArray());
strCiphered.Close();
}

//Simple Private-Key Decryption Operation
private void buttonDecrypt_Click(object sender, EventArgs e)
{
string password = textBoxKey.Text;
string salt = textBoxSalt.Text;
string cipheredText = textBoxCiphered.Text;
byte[] cipheredBytes = Convert.FromBase64String(cipheredText);

//Rfc2898DeriveBytes: Used to Generate Strong Keys
Rfc2898DeriveBytes rfc = new Rfc2898DeriveBytes(password,
Encoding.ASCII.GetBytes(salt));//Non-English Alfhabets Will not Work on ASCII Encoding

SymmetricAlgorithm Alg = GetSelectedAlgorithm();

Alg.Key = rfc.GetBytes(Alg.KeySize / 8);
Alg.IV = rfc.GetBytes(Alg.BlockSize / 8);

MemoryStream strDeciphered = new MemoryStream();//To Store Decrypted Data

CryptoStream strCrypto = new CryptoStream(strDeciphered,
Alg.CreateDecryptor(), CryptoStreamMode.Write);

strCrypto.Write(cipheredBytes, 0, cipheredBytes.Length);
strCrypto.Close();
textBoxDeciphered.Text = Encoding.ASCII.GetString(strDeciphered.ToArray());
strDeciphered.Close();
}