Java Utililty Methods Digest

List of utility methods to do Digest

Description

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

Method

Stringdigest(String provider, File file, int radix)
Digest a file with a specified provider.
String result;
BufferedInputStream bis = null;
try {
    MessageDigest messageDigest = MessageDigest.getInstance(provider);
    bis = new BufferedInputStream(new FileInputStream(file));
    byte[] buffer = new byte[8192];
    int n;
    while ((n = bis.read(buffer)) != -1)
...
Stringdigest(String raw, String algorithm)
digest
if (raw == null || "".equals(raw))
    return "";
MessageDigest md;
try {
    md = MessageDigest.getInstance(algorithm);
} catch (NoSuchAlgorithmException e) {
    throw new RuntimeException(e);
md.update(raw.getBytes());
StringBuilder sb = new StringBuilder();
for (byte b : md.digest()) {
    String hex = String.format("%02x", b);
    sb.append(hex);
return sb.toString();
Stringdigest(String s, String algorithm)
Computes digest of given input String.
int i;
MessageDigest md = MessageDigest.getInstance(algorithm);
byte[] hash = md.digest(s.getBytes());
StringBuilder sb = new StringBuilder(2 * hash.length);
for (i = 0; i < hash.length; i++) {
    int b = hash[i] & 0xff;
    if (b < 16) {
        sb.append('0');
...
byte[]digest(String source)
digest
MessageDigest md = MessageDigest.getInstance("SHA1");
md.update(source.getBytes());
return md.digest();
Stringdigest(String source, byte[] salt)
digest
try {
    return new String(encode(digest(source.getBytes(DEFAULT_ENCODING), salt)));
} catch (UnsupportedEncodingException ex) {
    throw new RuntimeException("PasswordCrypter's error has occured!", ex);
} catch (RuntimeException ex) {
    throw ex;
Stringdigest(String source, String algorythm)
digest
if (source == null || source.length() == 0) {
    return source;
try {
    StringBuilder result = new StringBuilder();
    MessageDigest md = MessageDigest.getInstance(algorythm);
    byte[] bytes = md.digest(source.getBytes("UTF-8"));
    for (byte b : bytes) {
...
Stringdigest(String strSource)
digest
StringBuffer digest = new StringBuffer();
java.security.MessageDigest md = java.security.MessageDigest.getInstance("SHA");
byte[] sourBytes = strSource.getBytes();
byte[] digestBytes = md.digest(sourBytes);
if (digestBytes != null) {
    for (int i = 0, n = digestBytes.length; i < n; i++) {
        digest.append(digestBytes[i]);
return digest.toString();
Stringdigest(String strSrc, String encName)
digest
MessageDigest md = null;
String strDes = null;
byte[] bt = strSrc.getBytes();
try {
    if (encName == null || encName.equals("")) {
        encName = "MD5";
    md = MessageDigest.getInstance(encName);
...
Stringdigest(String text)
digest
MessageDigest algorithm = null;
StringBuilder sig = new StringBuilder();
try {
    algorithm = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException exc) {
    throw new RuntimeException(exc);
algorithm.reset();
...
Stringdigest(String text, String algorithm)
Create the hash/digest code for a given text.
if (text == null) {
    throw new IllegalArgumentException(new NullPointerException());
MessageDigest md;
try {
    md = MessageDigest.getInstance(algorithm);
} catch (NoSuchAlgorithmException e) {
    throw new IllegalArgumentException(e);
...