Best Online Casinos
1. Sol Casino
Free Sign-Up Bonus: 90 Free Spins ( Free Sign-Up Bonus Link )
First Deposit Bonus: 200% up to €/$ 200 ( Registration Link )
2. Fresh Casino
Free Sign-Up Bonus: 40 Free Spins ( Free Sign-Up Bonus Link )
First Deposit Bonus: 100% up to €/$ 300 ( Registration Link )
3. Jet Casino
Free Sign-Up Bonus: 60 Free Spins ( Free Sign-Up Bonus Link )
First Deposit Bonus: 200% up to €/$ 200 ( Registration Link )
SHA256 or SHA512 on a UWP 10 Mobile .NET game
- Blog
- Forums
- Answers
- Evangelists
- User Groups
- Beta Program
- Advisory Panel
Search Unity
Unity ID
A Unity ID allows you to buy and/or subscribe to Unity products and services, shop in the Asset Store and participate in the Unity community.
-
Forums
- Menu
-
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:
- 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;
- Wscc.HashAlgorithmProvider hashAlgo = Wscc.HashAlgorithmProvider.OpenAlgorithm(Wscc.HashAlgorithmNames.Sha256);
- using (System.Security.Cryptography.HashAlgorithm hashAlgo = new System.Security.Cryptography.SHA256Managed())
- IBuffer input = CryptographicBuffer.ConvertStringToBinary(“Example”, BinaryStringEncoding.Utf8);
- byte[] hashBytes = hashAlgo.HashData(input).ToArray();
- byte[] input = System.Text.Encoding.UTF8.GetBytes(“Example”);
- byte[] hashBytes = hashAlgo.ComputeHash(input);
Consider using HMAC-SHA256 instead of plain SHA256 with home-made salting.
-
Thank you, I’ll try this and let you know.