List of utility methods to do SHA1
String | sha1hex(String source) Returns a hex string representing the SHA-1 encoded source. return hexlate(digest("SHA-1", source)); |
String | sha1Java(String password) sha Java MessageDigest md; byte[] sha1hash = new byte[40]; try { md = MessageDigest.getInstance("SHA-1"); md.update(password.getBytes("iso-8859-1"), 0, password.length()); sha1hash = md.digest(); } catch (Exception e) { return convertToHex(sha1hash); |
byte[] | sha1Sum(byte[] ba) This method is used to calculate key identifiers. byte[] digest = null; MessageDigest md = null; try { md = MessageDigest.getInstance("SHA-1"); md.update(ba); digest = md.digest(); } catch (NoSuchAlgorithmException e) { return digest; |
byte[] | sha1sum(byte[] data, Integer startIdxInc, Integer stopIdxExc) shasum byte[] out; MessageDigest md; md = MessageDigest.getInstance("SHA-1"); out = md.digest(data); if (startIdxInc != null && stopIdxExc != null) { out = Arrays.copyOfRange(out, startIdxInc, stopIdxExc); return out; ... |
String | sha1sum(byte[] input, int length) shasum try { MessageDigest sha1 = MessageDigest.getInstance("SHA1"); sha1.update(input, 0, length); return getHex(sha1.digest()); } catch (NoSuchAlgorithmException e) { return null; |
String | sha1sum(File file) shasum String localSha1Sum = null; if (file.exists() && file.isFile() && file.canRead()) { DigestInputStream dis = null; try { MessageDigest md = MessageDigest.getInstance("SHA-1"); dis = new DigestInputStream(new FileInputStream(file), md); dis.on(true); while (dis.read() != -1) { ... |
String | sha1sum(File file) shasum InputStream in = new FileInputStream(file); String cs = checksum("SHA-1", in); in.close(); return cs; |
byte[] | SHA1Sum(final @Nonnull byte[] bytes) SHA Sum return sha1.digest(bytes);
|
String | sha1sum(final String data) shasum final MessageDigest md; try { md = MessageDigest.getInstance("SHA-1"); } catch (final NoSuchAlgorithmException ignored) { return data; return byteArrayToHexString(md.digest(getBytesUtf8(data))); |
String | sha1sum(InputStream file) shasum InputStream in = file; try { MessageDigest digest = MessageDigest.getInstance("SHA1"); byte[] buffer = new byte[8192]; int read = 0; while ((read = in.read(buffer)) > 0) { digest.update(buffer, 0, read); byte[] sha1sum = digest.digest(); BigInteger bigInt = new BigInteger(1, sha1sum); return bigInt.toString(16); } catch (Exception e) { throw new RuntimeException("Unable to process file for MD5", e); } finally { if (in != null) try { in.close(); } catch (IOException e) { throw new RuntimeException("Unable to close input stream for MD5 calculation", e); |