2
I’m trying to encrypt a string in a UWP (Universal Windows Platform) application and decrypt the string in a Web API application.
The problem is that I can’t find/modify an algorithm common to both platforms.
Currently I use the code below in the UWP project to encrypt
SymmetricKeyAlgorithmProvider aesCbcPkcs7 = SymmetricKeyAlgorithmProvider
.OpenAlgorithm(SymmetricAlgorithmNames.AesCbcPkcs7);
IBuffer keymaterial = CryptographicBuffer.ConvertStringToBinary(CHAVE,
BinaryStringEncoding.Utf8);
CryptographicKey k = aesCbcPkcs7.CreateSymmetricKey(keymaterial);
byte[] value = Encoding.UTF8.GetBytes("STRING");
IBuffer buff = CryptographicEngine.Encrypt(k,
CryptographicBuffer.CreateFromByteArray(value),
keymaterial);
return CryptographicBuffer.EncodeToBase64String(buff);
But when I try to decrypt within the Web API project I get the error: Operation is not supported on this Platform
How to make an algorithm that works on both platforms?