Java Utililty Methods MD5 String

List of utility methods to do MD5 String

Description

The list of methods to do MD5 String are organized into topic(s).

Method

Stringmd5Digest(String word)
md Digest
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    md.update(word.getBytes());
    byte[] byteData = md.digest();
    StringBuilder hexString = new StringBuilder();
    for (int i = 0; i < byteData.length; i++) {
        String hex = Integer.toHexString(0xff & byteData[i]);
        if (hex.length() == 1)
...
Stringmd5DigestPassword(String password)
Creates a MD5 digest String from a given password.
try {
    MessageDigest md = MessageDigest.getInstance("MD5");
    return hexEncode(md.digest(password.getBytes()));
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException("No MD5 algorithm present on the system");
Stringmd5EncriptionPassword(String str)
md Encription Password
if (str == null || str.length() == 0) {
    throw new IllegalArgumentException("String to encript cannot be null or zero length");
digester.update(str.getBytes());
byte[] hash = digester.digest();
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < hash.length; i++) {
    if ((0xff & hash[i]) < 0x10) {
...
Stringmd5encrypt(String phrase)
mdencrypt
return generateHash(phrase, "MD5");
Stringmd5Encrypt(String str)
md Encrypt
if (str == null)
    return str;
MessageDigest localMessageDigest = null;
try {
    localMessageDigest = MessageDigest.getInstance(MD5_DIGEST);
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
localMessageDigest.update(str.getBytes());
byte[] arrayOfByte = localMessageDigest.digest();
return byte2Hex(arrayOfByte);
Stringmd5Encrypt(String str)
md Encrypt
byte[] bytes = null;
try {
    bytes = str.getBytes("UTF-8");
} catch (Exception e) {
    bytes = str.getBytes();
byte messageDigest[] = null;
synchronized (m_md5) {
...
Stringmd5Encryption(String str)
md Encryption
byte[] newStr = null;
try {
    MessageDigest md5 = MessageDigest.getInstance("MD5");
    Encoder base = Base64.getEncoder();
    newStr = base.encode(md5.digest(str.getBytes("UTF-8")));
} catch (Exception e) {
    e.printStackTrace();
return newStr.toString();
Stringmd5File(File f)
md File
MessageDigest md = null;
InputStream is = null;
try {
    md = MessageDigest.getInstance("MD5");
    is = new FileInputStream(f);
    is = new DigestInputStream(is, md);
    byte[] buffer = new byte[4096];
    while (is.read(buffer) != -1) {
...
Stringmd5file(File file)
mdfile
byte[] _bytes = null;
InputStream is = new FileInputStream(file);
MessageDigest digest = MessageDigest.getInstance("MD5");
byte[] buffer = new byte[8192];
int read = 0;
while ((read = is.read(buffer)) > 0) {
    digest.update(buffer, 0, read);
_bytes = digest.digest();
if (is != null) {
    is.close();
    is = null;
return new BigInteger(1, _bytes).toString(16);
Stringmd5FromFile(File file)
md From File
if (!file.exists()) {
    return "";
MessageDigest md = null;
try {
    md = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
...