Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.math.BigInteger;
- import java.security.MessageDigest;
- import java.security.NoSuchAlgorithmException;
- import java.util.Arrays;
- public class Main {
- /**
- * @param args
- * @throws NoSuchAlgorithmException
- * @throws UnsupportedEncodingException
- */
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- String pass = "blabla";
- String salt = "9B3AF463E1270DC5511D86293D23C0D1"; //Result suppose to be 535791F2391DCE9AD6FEBB9C49DC53FD
- // convert your hex string to bytes
- byte[] bytesSalt = new BigInteger(salt, 16).toByteArray();
- byte[] bytePass = pass.getBytes();
- // get the MD5 digest library, not sure why this isn't just part of the jdk
- MessageDigest md5Digest = null;
- try {
- md5Digest = MessageDigest.getInstance("MD5");
- } catch (NoSuchAlgorithmException e) {
- // error handling here...
- }
- // add the bytes to our digest
- md5Digest.update(bytesSalt);
- md5Digest.update(bytePass);
- // get the digest bytes
- byte[] digestBytes = md5Digest.digest();
- System.out.println("Digest is " + Arrays.toString(digestBytes));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement