Hacker rank 56th solution java(java md5)
56. JAVA MD5
// MD5 IS A TECHNIQUE FOR ENCRYPTION
import java.security.MessageDigest;
import java.util.Scanner;
public class Solution {
public static void main(String[] argh) {
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 e) {
throw new RuntimeException(e);
}
}
}
Comments