简体   繁体   English

在WP8上解密AES 128位Rijndael

[英]Decrypt AES 128bit RijndaelManaged on WP8

i'm having some trouble with this code. 我在这段代码上遇到了麻烦。

var symmetricKey = new RijndaelManaged { Mode = CipherMode.CBC, IV = iv, KeySize = 128, Key = keyBytes, Padding = PaddingMode.Zeros };

using (var decryptor = symmetricKey.CreateDecryptor())
using (var ms = new MemoryStream(cipherTextBytes))
using (var cs = new CryptoStream(ms, decryptor, CryptoStreamMode.Read))
{
    var plainTextBytes = new byte[cipherTextBytes.Length];
    int decryptedByteCount = cs.Read(plainTextBytes, 0, plainTextBytes.Length);
    return Encoding.UTF8.GetString(plainTextBytes, 0, decryptedByteCount);
}

The problem is here: 问题在这里:

var symmetricKey = new RijndaelManaged { Mode = CipherMode.CBC, IV = iv,
                                         KeySize = 128, Key = keyBytes,
                                         Padding = PaddingMode.Zeros };

Because even if i have included the System.Security.Cryptography , it doesn't find the RijndaelManaed . 因为即使我已经包含System.Security.Cryptography ,它也找不到RijndaelManaed It says: 它说:

" Namespace not found. Probably using or assembly reference " “找不到命名空间。可能使用或汇编参考”

In fact, when i add using System.Security.Cryptography , only options available are: 实际上,当我using System.Security.Cryptography添加时,只有可用的选项是:

  • Pkcs PKCS
  • X509Certificates X509Certificates
  • Xml XML

I need to use System.Security.Cryptography.RijndaelManaged 我需要使用System.Security.Cryptography.RijndaelManaged

It seems .NET for Windows Store Apps simply does not have System.Security.Cryptography.RijndaelManaged . 似乎Windows Store Apps的.NET根本没有System.Security.Cryptography.RijndaelManaged

The Windows.Security.Cryptography namespace only has one class: CryptographicBuffer . Windows.Security.Cryptography命名空间只有一个类: CryptographicBuffer

You'll have to use SymmetricKeyAlgorithmProvider.OpenAlgorithm to choose a symmetric encryption algorithm. 您必须使用SymmetricKeyAlgorithmProvider.OpenAlgorithm来选择对称加密算法。 Here you'll find a list of all the symmetric algorithms supporter on WinRT. 在这里,您会找到WinRT上所有对称算法支持者的列表。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM