Para utilizar criptografia MD5 no java importe as seguintes classes:
import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.math.BigInteger;
Utilize o método abaixo:
public String md5(String senha) throws NoSuchAlgorithmException { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(senha.getBytes()); BigInteger hash = new BigInteger(1, md.digest()); return hash.toString(16); }
