Created
February 15, 2017 16:15
-
-
Save spot62/c76a62e0658aca1c0dc94b007d7c09d7 to your computer and use it in GitHub Desktop.
Java MD5
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.util.*; | |
import java.text.*; | |
import java.math.*; | |
import java.util.regex.*; | |
import java.io.UnsupportedEncodingException; | |
import java.security.NoSuchAlgorithmException; | |
public class Solution { | |
public static void main(String[] args) throws NoSuchAlgorithmException, UnsupportedEncodingException { | |
try { | |
Scanner in = new Scanner(System.in); | |
String text = in.nextLine(); | |
java.security.MessageDigest md = java.security.MessageDigest.getInstance("MD5"); | |
byte[] array = md.digest(text.getBytes()); | |
StringBuffer sb = new StringBuffer(); | |
for (int i = 0; i < array.length; ++i) { | |
sb.append(Integer.toHexString((array[i] & 0xFF) | 0x100).substring(1,3)); | |
} | |
System.out.println(sb.toString()); | |
} | |
catch (java.security.NoSuchAlgorithmException e) { | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment