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

Stringsha1(String text)
sha
MessageDigest md = MessageDigest.getInstance("SHA-1");
md.update(text.getBytes("iso-8859-1"), 0, text.length());
byte[] sha1hash = md.digest();
return convertToHex(sha1hash);
StringSHA1(String texto)
SHA
String sen = "";
MessageDigest md = null;
try {
    md = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
BigInteger hash = new BigInteger(1, md.digest(texto.getBytes()));
...
Stringsha1(String txt)
sha
return hash("SHA1", txt);
byte[]sha1(String utf8)
sha
MessageDigest sha1 = MessageDigest.getInstance("SHA-1");
return sha1.digest(utf8.getBytes("UTF-8"));
Stringsha1(String value)
sha
try {
    return hash(MessageDigest.getInstance("SHA1"), value);
} catch (NoSuchAlgorithmException e) {
    e.printStackTrace();
return null;
Stringsha1(String value)
sha
return byte2hex(digest(value, SHA1));
Stringsha12String(MessageDigest messageDigest)
sha String
try (Formatter formatter = new Formatter()) {
    for (final byte b : messageDigest.digest()) {
        formatter.format("%02x", b);
    return formatter.toString();
Stringsha1_b64(final String text)
shb
try {
    final byte[] bytesOfMessage = text.getBytes();
    final MessageDigest md = MessageDigest.getInstance("SHA1");
    final byte[] digest = md.digest(bytesOfMessage);
    return base64encode(digest);
} catch (Exception e) {
    throw new RuntimeException();
StringSHA1_HEX(byte[] bytes)
SHHEX
try {
    return digest("SHA-1", bytes);
} catch (NoSuchAlgorithmException bytesz) {
return null;
byte[]sha1AsBytes(String input)
sha As Bytes
return sha1AsBytes(input.getBytes(StandardCharsets.UTF_8));