【C#】SHA256で16進数ハッシュ文字列の作成

C#, DEVELOP

using System.Security.Cryptography;
using System.Text;
using System.Linq;
 
string GetSHA256HashString(string _value)
{
    SHA256CryptoServiceProvider provider = new SHA256CryptoServiceProvider();
    return string.Join("", provider.ComputeHash(Encoding.UTF8.GetBytes(_value)).Select(x => $"{x:x2}"));
}

目次

テスト

var hash = GetSHA256HashString("kazupon");
Debug.Log(hash);

結果

47401e948bd455149b7f79f577f1e26773f0bef7f6770251da1d8538b7d62324

Posted by kazupon