I am trying to decrypt the given text with the key but i am getting error "The input data is not a complete block" Check code below and help if you can .
- private string DecryptOTP(string decryptethis)
- {
- decryptethis = "4931cb6f11c9f8b24f0b05f9ec9a2cc0";
- string decryptionKey = string.Empty;
- decryptionKey = "f22704b8bc0dcc606303b5eb97332630";
- byte[] cipherBytes = Convert.FromBase64String(decryptedOTP.Trim());
- using (Aes encryptor = Aes.Create())
- {
- Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(decryptionKey.Trim(), new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });
- encryptor.Key = pdb.GetBytes(32);
- encryptor.IV = pdb.GetBytes(16);
- using (MemoryStream ms = new MemoryStream())
- {
- using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
- {
- cs.Write(cipherBytes, 0, cipherBytes.Length);
- cs.Close();
- }
- decryptethis = Encoding.Unicode.GetString(ms.ToArray());
- }
- }
- return decryptethis;
- }