在hash加密的过程,执行所有必需的步骤,确保不会削弱所生成hash值的强度。
MessageDigest messageDigest = MessageDigest.getInstance("SHA-512");
messageDigest.update(inputText.getBytes());
byte byteBuffer[] = messageDigest.digest();
StringBuilder strHexString = new StringBuilder();
for (int i = 0; i < byteBuffer.length; i++) {
String hex = Integer.toHexString(0xff & byteBuffer[i]);
if (hex.length() == 1) {
strHexString.append('0');
}
strHexString.append(hex);
}
strResult = strHexString.toString();