Java版本:
public void testHash() { String password = "Test"; byte[] key = password.getBytes(); MessageDigest md = MessageDigest.getInstance("SHA-1"); byte[] hash = md.digest(key); String result = ""; for ( byte b : hash ) { result += Integer.toHexString(b + 256) + " "; } System.out.println(result); }
C#版本:
public void testHash() { String password = "Test"; byte[] key = System.Text.Encoding.Default.GetBytes(password); SHA1 sha1 = SHA1Managed.Create(); byte[] hash = sha1.ComputeHash(key); String result; foreach ( byte b in hash ) { result += Convert.ToInt32(b).ToString("x2") + " "; } Console.WriteLine(result); }
标签:key,hash,String,SHA,result,哈希,Java,byte,password
From: https://www.cnblogs.com/fyy1003668657/p/17585743.html