I need AES enryption/Decryption foe an app in wp8.1. I used AES managed class under system.securuty.cryptography namespace for the app in Wp8 . I came acreoss some references like replace the name space with Windows.security.cryptography. I tried and stil couldnt find any thing. Can Somebody help me with a sample?
I tried the following code and it says AES managed cannot be found
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.Security.Cryptography.Core;
//using Windows.Security.Cryptography.Core;
using Cimbalino.Toolkit.Extensions;
//using System.Security.Cryptography;
namespace telyads.Utils
{
class TACryptoModule
{
public string GenerateAESKey()
{
//var g = (Guid.NewGuid()).ToString();
//var key = g.GetBytes().ComputeMD5Hash().ToBase64String();
AesManaged KeyGen = new AesManaged();
return (KeyGen.Key).ComputeMD5Hash().ToBase64String();
}
public string AESEncrypt(string data, string key)
{
return null;
}
public string AESDecrypt(string data, string key)
{
return null;
}
}
}
You can use Visual Studio's Object Browser scoped to "My Solution" to find classes that exist for your solution type. Searching on AES finds several AES variants available in Windows.Security.Cryptography.Core . You can acquire a provider by passing a SymmetricKeyAlgorithm.Name to the SymmetricKeyAlgorithmProvider and then using it with the CryptographicEngine class.
string strAlgName = SymmetricAlgorithmNames.AesEcb;
SymmetricKeyAlgorithmProvider objAlg = SymmetricKeyAlgorithmProvider.OpenAlgorithm(strAlgName);
There is a fuller code snippet in the SymmetricKeyAlgorithmProvider.OpenAlgorithm documentation and in the Encrypting data and working with certificates section on MSDN.
You can find Windows.Security.Cryptography.Core.HashAlgorithmNames.Md5 in the same way and a snippet showing how to hash objects
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.