List of utility methods to do Digest
String | digest(String token) digest MessageDigest sha1 = MessageDigest.getInstance("SHA1"); return byteArrayToHexStr(sha1.digest(token.getBytes("UTF-8"))); |
byte[] | digest(String type, byte[] bytes) digest try { MessageDigest dist = MessageDigest.getInstance(type); return dist.digest(bytes); } catch (NoSuchAlgorithmException e) { throw new IllegalArgumentException("Cannot find digest:" + type, e); |
String | digest(String uri) digest try { MessageDigest algorithm = MessageDigest.getInstance("MD5"); algorithm.update(uri.getBytes()); byte messageDigest[] = algorithm.digest(); StringBuffer hexString = new StringBuffer(); for (int i = 0; i < messageDigest.length; i++) { hexString.append(Integer.toHexString(0xFF & messageDigest[i])); return "_" + hexString.toString(); } catch (NoSuchAlgorithmException nsae) { return uri.replaceAll("\\/|:|\\.|#|\\?|&|\\+|-|~", "_"); |
byte[] | digest(String value, byte[] salt, int iterations) digest MessageDigest digest = MessageDigest.getInstance(digestAlgorithm); digest.reset(); digest.update(salt); byte[] byteValue = digest.digest(value.getBytes(stringEncoding)); for (int i = 0; i < iterations; ++i) { digest.reset(); byteValue = digest.digest(byteValue); return byteValue; |
byte[] | digest(String value, String algorithm) digest if (value == null || "".equals(value.trim())) { return null; byte[] bytes = null; try { MessageDigest md = MessageDigest.getInstance(algorithm); bytes = md.digest(value.getBytes(CHARSET)); } catch (NoSuchAlgorithmException e) { ... |
UUID | digestBased(String text) Method used when an UUID must be generated using a string representation. assert text != null; final MessageDigest algo = MessageDigest.getInstance("MD5"); algo.reset(); algo.update(text.getBytes()); final byte[] digest = algo.digest(); assert digest.length == DIGEST_LEN; long mostSigBits = 0L; long leastSigBits = 0L; ... |
byte[] | digestBySHA256(byte[] source) digest MessageDigest md5Digest = getDigest(DIGEST_SHA_256);
return md5Digest.digest(source);
|
byte[] | digestBytes(String type, byte[]... data) digests all byte arrays via the method provided MessageDigest md = MessageDigest.getInstance(type); for (int i = 0; i < data.length; i++) { md.update(data[i]); return md.digest(); |
String | digestEncrypte(byte[] plainText, String algorithm) digest Encrypte MessageDigest md = MessageDigest.getInstance(algorithm); md.update(plainText); byte[] b = md.digest(); StringBuilder output = new StringBuilder(32); for (int i = 0; i < b.length; i++) { String temp = Integer.toHexString(b[i] & 0xff); if (temp.length() < 2) { output.append("0"); ... |
String | digestHex(String txt) Compute a MD5 hash from the text, represented as a hexadecimal string. return b2hex(digest(null, txt));
|