Francesco
Francesco

Reputation: 23

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. It says:

" Namespace not found. Probably using or assembly reference "

In fact, when i add using System.Security.Cryptography, only options available are:

I need to use System.Security.Cryptography.RijndaelManaged

Upvotes: 1

Views: 902

Answers (1)

dcastro
dcastro

Reputation: 68660

It seems .NET for Windows Store Apps simply does not have System.Security.Cryptography.RijndaelManaged.

The Windows.Security.Cryptography namespace only has one class: CryptographicBuffer.

You'll have to use SymmetricKeyAlgorithmProvider.OpenAlgorithm to choose a symmetric encryption algorithm. Here you'll find a list of all the symmetric algorithms supporter on WinRT.

Upvotes: 2

Related Questions