Java Code Examples for org.apache.commons.codec.digest.DigestUtils.md5()

The following are Jave code examples for showing how to use md5() of the org.apache.commons.codec.digest.DigestUtils class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: cos-java-sdk-v5   File: Md5Utils.java   View Source Code Vote up 7 votes
public static byte[] computeMD5Hash(InputStream is) throws IOException {
    return DigestUtils.md5(is);
}
 
Example 2
Project: Android_Code_Arbiter   File: WeakMessageDigest.java   View Source Code Vote up 5 votes
public static void apacheApiVariations() {

        printHex(DigestUtils.getMd2Digest().digest("123".getBytes()));
        printHex(DigestUtils.getMd5Digest().digest("123".getBytes()));
        printHex(DigestUtils.getDigest("md2").digest("123".getBytes()));
        printHex(DigestUtils.getDigest("md5").digest("123".getBytes()));
        DigestUtils.md2("123".getBytes());
        DigestUtils.md5("123".getBytes());
        System.out.println(DigestUtils.md2Hex("123".getBytes()));
        System.out.println(DigestUtils.md5Hex("123".getBytes()));

        printHex(DigestUtils.getSha1Digest().digest("123".getBytes()));
        printHex(DigestUtils.getShaDigest().digest("123".getBytes()));
        printHex(DigestUtils.getDigest("sha1").digest("123".getBytes()));
        printHex(DigestUtils.getDigest("sha-1").digest("123".getBytes()));
        DigestUtils.sha1("123".getBytes());
        DigestUtils.sha("123".getBytes());
        DigestUtils.sha1Hex("123".getBytes());
        DigestUtils.shaHex("123".getBytes());

        printHex(DigestUtils.getDigest("sha256").digest("123".getBytes())); //OK!
        printHex(DigestUtils.getDigest(getDigest()).digest("123".getBytes())); //Unknown
    }
 
Example 3
Project: MinecraftServerSync   File: FTPSyncClient.java   View Source Code Vote up 5 votes
private static byte[] computeMd5(Path localPath) throws IOException {
	if (!Files.exists(localPath)) {
		return new byte[0];
	}
	try (InputStream file = Files.newInputStream(localPath)) {
		return DigestUtils.md5(file);
	}
}
 
Example 4
Project: cos-java-sdk-v5   File: Md5Utils.java   View Source Code Vote up 4 votes
/**
 * Computes the MD5 hash of the given data and returns it as an array of bytes.
 */
public static byte[] computeMD5Hash(byte[] input) {
    return DigestUtils.md5(input);
}
 
Example 5
Project: sirocco   File: HashUtils.java   View Source Code Vote up 2 votes
/**
*  Calculates base64(md5(value)). 
*  This string is URL and JSON safe but 35% shorter than the simple MD5
* 
*  @param value - string to be hashed
*  @return A 21 byte string in base 64. 
*/
public static String getMD5HashBase64(String value)  {
    byte[] hash = DigestUtils.md5(value);
    return IdConverterUtils.convertByteArrayToBase64String(hash,null);
}