-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMD5.java
More file actions
23 lines (21 loc) · 732 Bytes
/
MD5.java
File metadata and controls
23 lines (21 loc) · 732 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import java.security.MessageDigest;
import java.util.*;
public class MD5 {
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc = new Scanner(System.in);
String str = sc.next();
sc.close();
try {
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(str.getBytes());
// return bytesToHex(md.digest
byte[] digest = md.digest();
for (byte b : digest) {
System.out.printf("%02x", b);
}
} catch (Exception ex) {
throw new RuntimeException(ex);
}
}
}