小编Вас*_*лов的帖子

如何修复 Rijndael Decryption 中的“Org.BouncyCastle.Crypto.InvalidCipherTextException:“pad 块损坏”

我有同样的情况Decrypt Rijndael 256 Block Size with BouncyCastle

所以我从那篇文章中修复了代码,并替换了我的旧代码

public static string Decrypt(string cipherText, string superSecretPassPhrase)
{
    if (cipherText == null)
    {
        throw new ArgumentNullException(nameof(cipherText));
    }
    // Get the complete stream of bytes that represent:
    // [32 bytes of Salt] + [32 bytes of IV] + [n bytes of CipherText]
    var cipherTextBytesWithSaltAndIv = Convert.FromBase64String(cipherText);
    // Get the saltbytes by extracting the first 32 bytes from the supplied cipherText bytes.
    var saltStringBytes = cipherTextBytesWithSaltAndIv.Take(Keysize / 8).ToArray();
    // Get the IV bytes …
Run Code Online (Sandbox Code Playgroud)

c# encryption bouncycastle rijndael

2
推荐指数
1
解决办法
2567
查看次数

标签 统计

bouncycastle ×1

c# ×1

encryption ×1

rijndael ×1