Example usage for org.apache.commons.codec.digest DigestUtils md5Hex

List of usage examples for org.apache.commons.codec.digest DigestUtils md5Hex

Introduction

In this page you can find the example usage for org.apache.commons.codec.digest DigestUtils md5Hex.

Prototype

public static String md5Hex(String data) 

Source Link

Usage

From source file:machinelabel.Hash.java

static String md5(String s) {
    return DigestUtils.md5Hex(s);
}

From source file:DigestUsage.java

public void start() {

    String hashData = "Hello World!!";

    System.err.println("Hello World!! as MD5 16 element hash: " + new String(DigestUtils.md5(hashData)));

    System.err.println("Hello World!! as MD5 Hex hash: " + DigestUtils.md5Hex(hashData));

    System.err.println("Hello World!! as SHA byte array hash: " + new String(DigestUtils.sha(hashData)));

    System.err.println("Hello World!! as SHA Hex hash: " + DigestUtils.shaHex(hashData));

}

From source file:com.qwazr.utils.HashUtils.java

public static String md5Hex(File file) throws IOException {
    FileInputStream fis = new FileInputStream(file);
    try {/*from ww  w . j  a  v a 2  s .co m*/
        BufferedInputStream bis = new BufferedInputStream(fis);
        try {
            return DigestUtils.md5Hex(bis);
        } finally {
            IOUtils.closeQuietly(bis);
        }
    } finally {
        IOUtils.closeQuietly(fis);
    }
}

From source file:be.vlaanderen.sesam.monitor.internal.util.BodyUtils.java

public static String getMd5Sum(File f) {
    FileInputStream fis = null;//from w w w.  j  a v a 2 s  . co m
    try {
        fis = new FileInputStream(f);
        String res = DigestUtils.md5Hex(fis);
        log.debug("Hashed file: {} -- {}", f.getName(), res);
        return res;
    } catch (IOException e) {
        log.warn("Failed calculating MD5sum. " + e.getMessage());
        return null;
    } finally {
        if (fis != null) {
            try {
                fis.close();
            } catch (IOException e) {
            }
        }
    }
}

From source file:alpine.util.GravatarUtil.java

/**
 * Generates a hash value from the specified email address.
 * Returns null if emailAddress is empty or null.
 * @param emailAddress the email address to generate a hash from
 * @return a hash value of the specified email address
 * @since 1.0.0/*from   w w  w . ja v a  2  s.  c  o m*/
 */
public static String generateHash(String emailAddress) {
    if (StringUtils.isBlank(emailAddress)) {
        return null;
    }
    return DigestUtils.md5Hex(emailAddress.trim().toLowerCase()).toLowerCase();
}

From source file:de.contentcreation.pplive.util.MD5Secure.java

/**
 * codiert einen String in ein md5Hash wert
 * @param encodeString/*from  w  ww .  ja va 2 s  .c  o  m*/
 * @return 
 */
public String encode(String encodeString) {
    String md5Hex = DigestUtils.md5Hex(encodeString);
    return md5Hex;
}

From source file:com.monitor.baseservice.utils.XCodeUtil.java

public synchronized static String getMD5(String source) {
    return DigestUtils.md5Hex(source);
}

From source file:com.abiquo.abiserver.business.authentication.TokenUtils.java

/**
 * Creates the authentication token signature.
 * /*from  ww  w  . j av  a  2  s  .  c o  m*/
 * @param tokenExpiryTime The token expiration time.
 * @param username The token user name.
 * @param password The token password.
 * @param key The token key.
 * @return The token.
 */
public static String makeTokenSignature(final long tokenExpiryTime, final String username,
        final String password) {
    return DigestUtils.md5Hex(username + ":" + tokenExpiryTime + ":" + password + ":abiquo-auth-key");
}

From source file:com.github.rnewson.couchdb.lucene.Utils.java

public static String digest(final String data) {
    return DigestUtils.md5Hex(data);
}

From source file:com.roche.sequencing.bioinformatics.common.utils.Md5CheckSumUtil.java

/**
 * return the md5 checksum for the string (note: this would be equivalent to writing this string to a file and asking for the md5sum of the file)
 * /*from ww w  .  j  av  a 2 s  . co m*/
 * @param string
 * @return the md5sum of the string or null if there was an error calculating the md5sum
 */
public static String md5sum(String string) {
    return DigestUtils.md5Hex(string);
}