-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathJavaMD5.java
More file actions
25 lines (23 loc) · 779 Bytes
/
JavaMD5.java
File metadata and controls
25 lines (23 loc) · 779 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
25
import java.io.*;
import java.util.*;
import java.security.MessageDigest;
import java.util.Scanner;
public class JavaMD5 {
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);
}
}
}