- Home /
Question by
akkiDev · Mar 25, 2015 at 09:04 AM ·
errorscript errorwindows store app
Reference Rewriter: Error: type `System.Security.Cryptography.HMACSHA1` doesn't exist in target framework.
I am using Unity 5, Build Plateform Windows Store Apps.
This works fine in Unity 4.3, but not working in Unity 5. I am using HMACSHA1 for making signature, it is very important for me, if this is not supported by windows store apps then any alternative/workaround.
Any help would be appreciated.
thanx.
Comment
Best Answer
Answer by akkiDev · Mar 26, 2015 at 07:26 AM
Got the Solution from Tomas1856 from forum thread. http://forum.unity3d.com/threads/reference-rewriter-error-type-system-security-cryptography-hmacsha1-doesnt-exist-in-target-fram.313589/#post-2038137
#if NETFX_CORE
using System.Runtime.InteropServices.WindowsRuntime;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
#endif
....
#if NETFX_CORE
private string GetSHA256Key(byte[] secretKey, string value)
{
var objMacProv = MacAlgorithmProvider.OpenAlgorithm(MacAlgorithmNames.HmacSha256);
var hash = objMacProv.CreateHash(secretKey.AsBuffer());
hash.Append(CryptographicBuffer.ConvertStringToBinary(value, BinaryStringEncoding.Utf8));
return CryptographicBuffer.EncodeToBase64String(hash.GetValueAndReset());
}
#endif