【发布时间】:2021-06-05 21:02:35
【问题描述】:
我正在从 .net 核心迁移到 reactjs,并且需要解密哈希到对象。我停留在结果不相等的地方。这是.net的代码。 注意:密文长度是656,这么长的数组不能贴在这里。
byte[] cipherText = [132, 185, 138, 129, 38, 216, 49, 48, 25, 139, 187, 146, 67, 234, 194, 143, 252, 214, 245, 230, 30, 238, 235, 53, 155, 136, 0, 112, 76, 27, 205, 84, 124, 250, 74, 114, 208, 227, 148, 135, 112, 168, 171, 73, 45, 122, 31, 248, 186, 80, 148, 143, 251, 216, 90, 152, 138, 130, 148, 199, 178, 151, 151, 195, 252, 43, 67, 183, 45, 24, 228, 73, 208, 249, 155, 36, 78, 232, 210, 20, 235, 109, 206, 245, 180, 28, 227, 32, 202, 143, 255, 110, 128, 38, 101, 174, 253, 80, 171, 201......]
plaintext = null;
byte[] Key = [56, 63, 82, 186, 73, 8, 112, 110, 129, 185, 157, 192, 163, 160, 120, 215, 52, 254, 252, 189, 25, 82, 43, 15, 87, 98, 48, 193, 21, 44, 6, 163]0: 561: 632: 823: 1864: 735: 86: 1127: 1108: 1299: 18510: 15711: 19212: 16313: 16014: 12015: 21516: 5217: 25418: 25219: 18920: 2521: 8222: 4323: 1524: 8725: 9826: 4827: 19328: 2129: 4430: 631: 163];
byte[] IV = [200, 97, 110, 6, 23, 248, 144, 210, 223, 167, 67, 64, 125, 96, 136, 201]
using (AesManaged aesAlg = new AesManaged())
{
aesAlg.Key = Key;
aesAlg.IV = IV;
ICryptoTransform decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
using (MemoryStream msDecrypt = new MemoryStream(cipherText))
{
using (CryptoStream csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
{
using (StreamReader srDecrypt = new StreamReader(csDecrypt))
{
plaintext = srDecrypt.ReadToEnd();
}
}
}
}
如何使用 cryptojs 解密字节数组?
【问题讨论】:
标签: javascript c# .net cryptography cryptojs