Unity ã§ SHA256 ãä½¿ãæ¹æ³
ã¾ãã¯æ¤è¨¼ç¨ã®ãã¼ã¿ã PHP ã§ä½æã以ä¸ã®ã³ãã³ããå®è¡ã
php -r 'echo hash_hmac("sha256", "apple", "secret_key")."\n";'
çµæã¯ãã¡ãã¯
ba6b88d8c49940b6424e053aef2ba049bbae3ed3b44c0cbb74bf5f1e32726b70
Unity ã§ã apple 㨠secret_key ã弿°ã«ã㦠ba6b88d8c49940b6424e053aef2ba049bbae3ed3b44c0cbb74bf5f1e32726b70 ãè¿ã£ã¦æ¥ãã°æåã§ãã
ããã°ã©ã ã®ä¸»ãªé¨åã¯ãã¡ã( C# ã®ããã°ã©ã ã§ã)ã
string sha256(string planeStr, string key) { System.Text.UTF8Encoding ue = new System.Text.UTF8Encoding(); byte[] planeBytes = ue.GetBytes(planeStr); byte[] keyBytes = ue.GetBytes(key); System.Security.Cryptography.HMACSHA256 sha256 = new System.Security.Cryptography.HMACSHA256(keyBytes); byte[] hashBytes = sha256.ComputeHash(planeBytes); string hashStr = ""; foreach(byte b in hashBytes) { hashStr += string.Format("{0,0:x2}", b); } return hashStr; } void Start () { string res = sha256("apple", "secret_key"); Debug.Log(res); }
å®è¡ããæã console ã«è¡¨ç¤ºãããæå㯠ba6b88d8c49940b6424e053aef2ba049bbae3ed3b44c0cbb74bf5f1e32726b70 ãæ£ããã SHA256 ã§ããã·ã¥åãããå¤ãåå¾ã§ãã¾ããã
é¢é£æ å ±
MD5 - Unify Community Wiki
http://wiki.unity3d.com/index.php?title=MD5
Unity ã§ SHA1(ã¡ãã»ã¼ã¸ãã¤ã¸ã§ã¹ã) ãçæããæ¹æ³ - å¼·ç«ã§é²ã
http://d.hatena.ne.jp/nakamura001/20130115/1358265478