I'm trying to get a hash of a string with SHA256 in my C# code, in Unity. I did the following:
using UnityEngine;
using System;
using System.IO;
using System.Security.Cryptography;
using System.Text;
public class URLGenerator : MonoBehaviour {
void Start () {
Debug.Log("myString: " + myString);
SHA256 mySHA256 = SHA256Managed.Create();
myHashBytes = mySHA256.ComputeHash(Encoding.ASCII.GetBytes(myString));
string myHash = Encoding.ASCII.GetString(myHashBytes);
Debug.Log("myHash: " + myHash);
}
}
Here's the result:
myString: 3272017110434AMbx78va23
myHash: ?)wP<??|-?)??V:?3?6"???????a??
Are the ?
representing invalid characters? If yes, why are they appearing? Did I do forgot something?