string ServerRetureMessage = "w1rt5RuOlgQirdbMUGPqOC4OdeKCAN9nauRn8j2tf1bRfapZBncAoq6vgZMqM4uhydhYoqCSvtX8cpDSwzUaLcFvx9bG3MmSAlTXH2scHjE=";
//编码到Base64
//使用AES解密
public static string AESDecryption(byte[] bytes)
{
string key = "&ujdk1(7q12kjrhq";
string iv = "2012010298weishu";
byte[] iv1 = Convert.FromBase64String(iv);
// Declare a buffer to contain the decrypted data.
IBuffer buffDecrypted;
var encoding = BinaryStringEncoding.Utf8;
// Open an symmetric algorithm provider for the specified algorithm.
SymmetricKeyAlgorithmProvider objAlg = SymmetricKeyAlgorithmProvider.OpenAlgorithm(SymmetricAlgorithmNames.AesCbcPkcs7);
// Create Key for algorithem provider
IBuffer keyMaterial = CryptographicBuffer.ConvertStringToBinary(key, encoding);
IBuffer IV = BytesToBuffer(iv1);
CryptographicKey cryptographicKey = objAlg.CreateSymmetricKey(keyMaterial);
IBuffer buffEncrypt = BytesToBuffer(bytes);
buffDecrypted = CryptographicEngine.Decrypt(cryptographicKey, buffEncrypt, IV);
string result = CryptographicBuffer.ConvertBinaryToString(BinaryStringEncoding.Utf8, buffDecrypted);
return result;
}
ServerRetureMessage 是服务器返回的一段加密的数据,服务器上采用的是AES加密,并且提供了key和IV,如何解密ServerRetureMessage 呢?我调用解密方法时会报错,不知道哪里有问题 ?求帮助
338

被折叠的 条评论
为什么被折叠?



