Java Utililty Methods SHA1

List of utility methods to do SHA1

Description

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

Method

Stringsha1hash(String key)
shahash
return hashWithAlgorithm(HASH_ALGORITHM_SHA1, key);
Stringsha1Hash(String s)
sha Hash
if (s == null) {
    return null;
final MessageDigest messageDigest;
try {
    messageDigest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
    throw new IllegalStateException(e);
...
Stringsha1Hash(String source)
sha Hash
MessageDigest digest = MessageDigest.getInstance("SHA1");
digest.update(source.getBytes(), 0, source.length());
return String.format("%040X", new BigInteger(1, digest.digest()));
Stringsha1Hash(String text)
Compute the SHA-1 hash of a string, and return it has a string of hexadecimal numbers.
return bytesToHex(computeHash(text, HASH_SHA1));
Stringsha1Hash(String toHash)
sha Hash
byte[] uniqueKey = toHash.getBytes();
byte[] hash = null;
hash = MessageDigest.getInstance("SHA1").digest(uniqueKey);
StringBuilder hashString = new StringBuilder();
for (int i = 0; i < hash.length; i++) {
    String hex = Integer.toHexString(hash[i]);
    if (hex.length() == 1) {
        hashString.append('0');
...
Stringsha1Hash(String tohash)
sha Hash
byte[] b = tohash.getBytes("UTF-8");
MessageDigest sha1 = MessageDigest.getInstance("SHA");
b = sha1.digest(b);
return byteToHex(b);
Stringsha1HashHex(String data)
sha Hash Hex
return sha1HashHex(data.getBytes());
intsha1HashInt(String text)
Compute the SHA-1 hash of a string, and return a truncated int-value of the hash.
return truncateHashToInt(computeHash(text, HASH_SHA1));
Stringsha1Hex(byte[] bytes)
sha Hex
return toHex(sha1(bytes));
Stringsha1Hex(String data)
sha Hex
if (data == null) {
    throw new IllegalArgumentException("data must not be null");
byte[] bytes = digest("SHA1", data);
return toHexString(bytes);