Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MessageDigest md;
- try
- {
- 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.substring(0, 16));
- } catch (NoSuchAlgorithmException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement