I have made some code that allows me to do cryptography in c# - using primarily AesManaged()
and SHA256Managed()
in System.Security.Cryptography.
The use case is that the tool needs to be able to pull off an encrypted piece of data, decrypt it, display it to the user, allow for editing and encrypt again before sending it back again.
I would like to be able to do similar on Windows Phone, but it seems that the namespace is not available on the phone.
So what are my options now? Will it be available on Windows Phone 10? It seems that doing crypto-stuff would be a relatively common task in a phone app?
Edit: added information about what the app should do
As @WDS noted, the tools for doing cryptography is located in Windows.Security.Cryptography namespace - available on #WP8 .
So I rewrote my hash-implementation like this:
public IBuffer ComputeHash(string value)
{
IBuffer buffUtf8Msg = CryptographicBuffer.ConvertStringToBinary(value, BinaryStringEncoding.Utf8);
var objAlgProv = HashAlgorithmProvider.OpenAlgorithm("SHA256");
var strAlgNameUsed = objAlgProv.AlgorithmName;
var buffHash = objAlgProv.HashData(buffUtf8Msg);
if (buffHash.Length != objAlgProv.HashLength)
{
throw new Exception("There was an error creating the hash");
}
return buffHash;
}
Examples of how to do encryption and decryption can be found here: