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

The following are Jave code examples for showing how to use sha1() 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: Android_Code_Arbiter   File: WeakMessageDigest.java   View Source Code Vote up 6 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 2
Project: sirocco   File: HashUtils.java   View Source Code Vote up 2 votes
/**
*  Calculates base64(sha1(value)) 
*  This string is URL and JSON safe but 35% shorter than the simple SHA1
* 
*  @param value - string to be hashed
*  @return A 21 byte string in base 64. 
*/
public static String getSHA1HashBase64(String value) {
    byte[] hash = DigestUtils.sha1(value);
    return IdConverterUtils.convertByteArrayToBase64String(hash,null);
}