SHA256 or SHA512 on a UWP 10 Mobile .NET game

I wanted to add SHA512 to check if my save game has been edited. But i get this error

Assets\scr.cs(29,17): error CS0246: The type or namespace name 'SHA256' could not be found (are you missing a using directive or an assembly reference?)

This works on a IL2CPP scripting backend game.
But the unity IAP system doesnt work on IL2CPP.

IAP is the priority so is there anyway that i can use SHA256 or SHA512 on .NET scripting backend with Universal 10 module?

Yes, but crypto API has changed.

You should use namespaces Windows.Security.Cryptography and Windows.Security.Cryptography.Core — you can import them entirely; or (to avoid scope pollution) can introduce explicit aliases for just the types you need (if you don’t mind verbosity), for example:

#if NETFX_CORE
using System.Runtime.InteropServices.WindowsRuntime;
using Wscc = Windows.Security.Cryptography.Core;
using BinaryStringEncoding = Windows.Security.Cryptography.BinaryStringEncoding;
using CryptographicBuffer = Windows.Security.Cryptography.CryptographicBuffer;
using CryptographicEngine = Windows.Security.Cryptography.Core.CryptographicEngine;
using CryptographicKey = Windows.Security.Cryptography.Core.CryptographicKey;
using MacAlgorithmNames = Windows.Security.Cryptography.Core.MacAlgorithmNames;
using MacAlgorithmProvider = Windows.Security.Cryptography.Core.MacAlgorithmProvider;
using IBuffer = Windows.Storage.Streams.IBuffer;
#endif
#if NETFX_CORE
    Wscc.HashAlgorithmProvider hashAlgo = Wscc.HashAlgorithmProvider.OpenAlgorithm(Wscc.HashAlgorithmNames.Sha256);
#else
    using (System.Security.Cryptography.HashAlgorithm hashAlgo = new System.Security.Cryptography.SHA256Managed())
#endif
    {
#if NETFX_CORE
        IBuffer input = CryptographicBuffer.ConvertStringToBinary("Example", BinaryStringEncoding.Utf8);
        byte[] hashBytes = hashAlgo.HashData(input).ToArray();
#else
        byte[] input = System.Text.Encoding.UTF8.GetBytes("Example");
        byte[] hashBytes = hashAlgo.ComputeHash(input);
#endif

Consider using HMAC-SHA256 instead of plain SHA256 with home-made salting.

Thank you, I’ll try this and let you know.