- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankJava0046.java
More file actions
Latest commit
24 lines (17 loc) · 673 Bytes
/
Copy pathHackerrankJava0046.java
File metadata and controls
24 lines (17 loc) · 673 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
importjava.nio.charset.StandardCharsets;
importjava.security.MessageDigest;
importjava.security.NoSuchAlgorithmException;
importjava.util.Scanner;
importjavax.xml.bind.DatatypeConverter;
publicclassHackerrankJava0046 {
publicstaticvoidmain(String[] args) throwsNoSuchAlgorithmException {
// Java SHA-256
// https://www.hackerrank.com/challenges/sha-256/problem?isFullScreen=true
Scannerscanner = newScanner(System.in);
MessageDigestmd = MessageDigest.getInstance("SHA-256");
md.update(scanner.next().getBytes());
Stringhash = DatatypeConverter.printHexBinary(md.digest()).toLowerCase();
System.out.println(hash);
scanner.close();
}
}