All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jelastic.api.utils.MD5 Maven / Gradle / Ivy

The newest version!
/*Server class MD5: eb4cb1ea4258db234ab0dfd7b1df6e9f*/
package com.jelastic.api.utils;

import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

/**
 * @name Jelastic API Client
 * @version 8.11.2
 * @copyright Jelastic, Inc.
 */
public class MD5 {

    public String get(StringBuffer str) {
        return get(str.toString());
    }

    public String get(StringBuilder str) {
        return get(str.toString());
    }

    public String get(String str) {
        String md5 = null;
        try {
            MessageDigest m = MessageDigest.getInstance("MD5");
            m.update(str.getBytes(StandardCharsets.UTF_8));
            md5 = new BigInteger(1, m.digest()).toString(16);
            while (md5.length() < 32) {
                md5 = "0" + md5;
            }
        } catch (NoSuchAlgorithmException ex) {
            ex.printStackTrace();
        }
        return md5;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy