Мой код работал раньше, когда я использовал RijndaelManaged.< /p>
Код: Выделить всё
public static string DecryptStringAES(string encryptedText, string key)
{
var keybytes = Encoding.UTF8.GetBytes(key);
var iv = keybytes;
var encryptStringToBytes = EncryptStringToBytes_Aes(encryptedText, keybytes, iv);
// Decrypt the bytes to a string. here encryptStringToBytes is byte[80]
var roundtrip = DecryptStringFromBytes_Aes(encryptStringToBytes, keybytes, iv);
//DECRYPT FROM CRIPTOJS
var encrypted = Convert.FromBase64String(roundtrip);
//here encryptStringToBytes is byte[48]
//This Line throws the exception --Padding is invalid and cannot be removed
var id = DecryptStringFromBytes_Aes(encrypted, keybytes, iv);
return id;
}
private static string DecryptStringFromBytes_Aes(byte[] cipherText, byte[] Key, byte[] IV)
{
if (cipherText == null || cipherText.Length
Подробнее здесь: [url]https://stackoverflow.com/questions/79090265/padding-is-invalid-and-cannot-be-removed-while-decrypting-using-aes[/url]
Мобильная версия