📜  java sha-256加密解密示例——Java代码示例

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

代码示例5
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());