java sha256 hex digest

Solutions on MaxInterview for java sha256 hex digest by the best coders in the world

showing results for - "java sha256 hex digest"
Paola
30 Sep 2020
1import org.apache.commons.codec.digest.DigestUtils;
2
3String password = "123456";
4String result = DigestUtils.sha256Hex(password);
Nicolò
07 Feb 2017
1String password = "123456";
2
3MessageDigest md = MessageDigest.getInstance("SHA-256");
4byte[]hashInBytes = md.digest(password.getBytes(StandardCharsets.UTF__8));
5
6//bytes to hex
7StringBuilder sb = new StringBuilder();
8for (byte b : hashInBytes) {
9	sb.append(String.format("%02x", b));
10}
11System.out.println(sb.toString());