对于SHA-256,Javascript和Android中相同字符串的哈希值不同:
Javascript代码:
var hashedPassword = CryptoJS.SHA256(userPassword);
var passwordText = hashedPassword.toString(CryptoJS.enc.Base64);
Android代码:
MessageDigest messageDigest = MessageDigest.getInstance("SHA-256");
byte[] hashedPassword = messageDigest.digest(userPassword.getBytes());
String hashedPasswordText = Base64.encodeToString(hashedPassword, Base64.DEFAULT).trim();
String“beast”的输出:
在Javascript中:
1bf417bd87162d5d77a5ce3259e81bdee9f8a0ef56bc0f12eadcd5805a94b708
在Android中:
G/QXvYcWLV13pc4yWegb3un4oO9WvA8S6tzVgFqUtwg=