Cannot find the encryption class AesManaged for windows store 8.1 RRS feed

  • Question

  • I created an Encryption helper class to encrypt and decrypt data for windows phone which used Aes encryption.
    Now I am creating the same application for windows 8.1 store apps. When I am trying to use the same code it cannot find the class AesManaged! I need to make this work, coz the same service is reused and the server decodes the data using aes encryption written in java.
    Previously AesManaged was inside System.Security.Cryptography.
    Now I am not sure where it is located. Could someone help?
    Tons of thanks in advance

    Below is the helper class:

    using System;
    using System.Text;
    //using System.Security.Cryptography;

    namespace Project.Core.Helper
        class EncryptionHelper
            public static string GetEncryptedString(string value)
                return Encrypt(value, ENCRYPTION_SECRETKEY);

            private static String Encrypt(String plainText, String key)
                var plainBytes = Encoding.UTF8.GetBytes(plainText);
                return Convert.ToBase64String(Encrypt(plainBytes, GetAesManaged(key)));

            private static byte[] Encrypt(byte[] plainBytes, AesManaged encryptor)
                return encryptor.CreateEncryptor()
                    .TransformFinalBlock(plainBytes, 0, plainBytes.Length);

            private static AesManaged GetAesManaged(string secretKey)
                var keyBytes = new byte[16];
                var secretKeyBytes = Encoding.UTF8.GetBytes(secretKey);
                Array.Copy(secretKeyBytes, keyBytes, Math.Min(keyBytes.Length, secretKeyBytes.Length));

                return new AesManaged()
                    KeySize = 128,
                    BlockSize = 128,
                    Key = keyBytes,
                    IV = keyBytes

    Monday, May 19, 2014 12:34 PM


  • The Windows Runtime cryptography classes are in Windows.Security.Cryptography.

    Take a look at the SymmetricAlgorithmNames property for several AES options.

    • Proposed as answer by Dave SmitsMVP Monday, May 19, 2014 8:39 PM
    • Marked as answer by Anne Jing Thursday, May 29, 2014 3:34 AM
    Monday, May 19, 2014 1:06 PM