/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @since 1.7 */ public static String sha1Hex(final String data) { return Hex.encodeHexString(sha1(data)); }
/** * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>. * * @param data * Data to digest * @return SHA-1 digest * @deprecated (1.11) Use {@link #sha1(byte[])} */ @Deprecated public static byte[] sha(final byte[] data) { return sha1(data); }
/** * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>. * * @param data * Data to digest * @return SHA-1 digest * @deprecated (1.11) Use {@link #sha1(String)} */ @Deprecated public static byte[] sha(final String data) { return sha1(data); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @since 1.7 */ public static String sha1Hex(final byte[] data) { return Hex.encodeHexString(sha1(data)); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @throws IOException * On error reading from the stream * @since 1.7 */ public static String sha1Hex(final InputStream data) throws IOException { return Hex.encodeHexString(sha1(data)); }
/** * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>. * * @param data * Data to digest * @return SHA-1 digest * @throws IOException * On error reading from the stream * @since 1.4 * @deprecated (1.11) Use {@link #sha1(InputStream)} */ @Deprecated public static byte[] sha(final InputStream data) throws IOException { return sha1(data); }
public static String filesystemSafeFileHash(File folder) { String hash = Base64.getEncoder().encodeToString(DigestUtils.sha1(folder.getAbsolutePath().getBytes())); hash = hash.replaceAll("[^0-9a-zA-Z\\.\\-]", ""); return hash; }
/** * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>. * * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return SHA-1 digest */ public static byte[] sha1(final String data) { return sha1(StringUtils.getBytesUtf8(data)); }
public static String sha1Digest(File file) { try(InputStream is = new BufferedInputStream(new FileInputStream(file))){ byte[] hash = DigestUtils.sha1(is); return Base64.getEncoder().encodeToString(hash); } catch (IOException e) { throw ExceptionUtils.bomb(e); } } }
private byte[] getAuthCipherBytes(final String password) { byte[] sha1Password = DigestUtils.sha1(password); byte[] doubleSha1Password = DigestUtils.sha1(sha1Password); byte[] concatBytes = new byte[authPluginData.getAuthPluginData().length + doubleSha1Password.length]; System.arraycopy(authPluginData.getAuthPluginData(), 0, concatBytes, 0, authPluginData.getAuthPluginData().length); System.arraycopy(doubleSha1Password, 0, concatBytes, authPluginData.getAuthPluginData().length, doubleSha1Password.length); byte[] sha1ConcatBytes = DigestUtils.sha1(concatBytes); return xor(sha1Password, sha1ConcatBytes); }
private byte[] getAuthCipherBytes(final String password) { byte[] sha1Password = DigestUtils.sha1(password); byte[] doubleSha1Password = DigestUtils.sha1(sha1Password); byte[] concatBytes = new byte[authPluginData.getAuthPluginData().length + doubleSha1Password.length]; System.arraycopy(authPluginData.getAuthPluginData(), 0, concatBytes, 0, authPluginData.getAuthPluginData().length); System.arraycopy(doubleSha1Password, 0, concatBytes, authPluginData.getAuthPluginData().length, doubleSha1Password.length); byte[] sha1ConcatBytes = DigestUtils.sha1(concatBytes); return xor(sha1Password, sha1ConcatBytes); }
@NotNull private String hash(@NotNull final String pString) { final String s = pString.replaceAll(Pattern.quote("\\"), "/"); final String h = new Base32().encodeAsString(DigestUtils.sha1(s)).toLowerCase(Locale.ENGLISH); final StringBuilder sb = new StringBuilder(h); for (int i = sb.length() - 1; i >= 0 && sb.charAt(i) == '='; i--) { sb.deleteCharAt(i); } return sb.toString(); }
/** * Calculates the SHA-1 digest and returns the value as a byte[]. * * @param input * the input * @return the SHA-1 digest */ public static final byte[] sha1(byte[] input) { return DigestUtils.sha1(input); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @since 1.7 */ public static String sha1Hex(final byte[] data) { return Hex.encodeHexString(sha1(data)); }
/** * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>. * * @param data * Data to digest * @return SHA-1 digest * @deprecated Use {@link #sha1(String)} */ @Deprecated public static byte[] sha(final String data) { return sha1(data); }
/** * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>. * * @param data * Data to digest * @return SHA-1 digest * @deprecated (1.11) Use {@link #sha1(byte[])} */ @Deprecated public static byte[] sha(final byte[] data) { return sha1(data); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @since 1.7 */ public static String sha1Hex(final String data) { return Hex.encodeHexString(sha1(data)); }
/** * Calculates the SHA-1 digest and returns the value as a hex string. * * @param data * Data to digest * @return SHA-1 digest as a hex string * @since 1.7 */ public static String sha1Hex(final byte[] data) { return Hex.encodeHexString(sha1(data)); }
/** * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>. * * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return SHA-1 digest */ public static byte[] sha1(final String data) { return sha1(StringUtils.getBytesUtf8(data)); }
/** * Calculates the SHA-1 digest and returns the value as a <code>byte[]</code>. * * @param data * Data to digest; converted to bytes using {@link StringUtils#getBytesUtf8(String)} * @return SHA-1 digest */ public static byte[] sha1(final String data) { return sha1(StringUtils.getBytesUtf8(data)); }