V
V
Vanes Ri_Lax2015-12-24 12:59:11
Java
Vanes Ri_Lax, 2015-12-24 12:59:11

Does Java have built-in MD5 functions?

Hello,
php has built-in functions for creating an MD5 hash, for example here: Is there something similar in java? Thank you very much in advance!
md5("test");

Answer the question

In order to leave comments, you need to log in

3 answer(s)
P
Peter, 2015-12-24
@vanesxl

import java.security.MessageDigest; 

String md5(String in) {
    	String result = null;
        try
        {
        	MessageDigest digest = MessageDigest.getInstance("MD5");
            digest.reset();
            digest.update(in.getBytes());
            BigInteger bigInt = new BigInteger(1, digest.digest());
            result = bigInt.toString(16);
        } catch (NoSuchAlgorithmException e) {
        	e.printStackTrace();
        }
        return result;
}

F
FoxInSox, 2015-12-24
@FoxInSox

Quite already, right?
1. Google: md5 java
2. First line: stackoverflow.com/questions/415953/how-can-i-gener...

A
Andrey Shishkin, 2015-12-24
@compiler

MD5 is not secure. Use SHA-2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question