hacker rank 57th solution in java(Java SHA-256)
57. Java SHA-256
import java.util.*;
import java.security.*;
public class Solution {
public static void main(String[] args) throws NoSuchAlgorithmException {
Scanner input = new Scanner(System.in);
MessageDigest m = MessageDigest.getInstance("SHA-256");
m.reset();
m.update(input.nextLine().getBytes());
for (byte i : m.digest()) {
System.out.print(String.format("%02x", i));
}
System.out.println();
}
}
Comments