📜  java sha256 十六进制摘要 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:05.758000             🧑  作者: Mango

代码示例2
String password = "123456";

MessageDigest md = MessageDigest.getInstance("SHA-256");
byte[]hashInBytes = md.digest(password.getBytes(StandardCharsets.UTF__8));

//bytes to hex
StringBuilder sb = new StringBuilder();
for (byte b : hashInBytes) {
    sb.append(String.format("%02x", b));
}
System.out.println(sb.toString());