/** * Returns digest of a file. Implementations may not read the whole * file into the memory. */ public byte[] digest(final File file) throws IOException;
/** * Returns string hash of input byte array. */ public default String digestString(final byte[] byteArray) { return StringUtil.toHexString(digest(byteArray)); }
/** * Returns string hash of input string. */ public default String digestString(final String input) { return StringUtil.toHexString(digest(input)); }
public default String digestString(final File file) throws IOException { return StringUtil.toHexString(digest(file)); }
/** * Creates digest i.e. bundle id from given string. * Returned digest must be filename safe, for all platforms. */ protected String createDigest(final String source) { final DigestEngine digestEngine = DigestEngine.sha256(); final byte[] bytes = digestEngine.digest(CharUtil.toSimpleByteArray(source)); String digest = Base32.encode(bytes); if (uniqueDigestKey != null) { digest += uniqueDigestKey; } return digest; }
/** * Returns string hash of input byte array. */ public default String digestString(final byte[] byteArray) { return StringUtil.toHexString(digest(byteArray)); }
/** * Returns digest of a file. Implementations may not read the whole * file into the memory. */ public byte[] digest(final File file) throws IOException;
/** * Returns string hash of input string. */ public default String digestString(final String input) { return StringUtil.toHexString(digest(input)); }
public default String digestString(final File file) throws IOException { return StringUtil.toHexString(digest(file)); }
/** * Creates digest i.e. bundle id from given string. * Returned digest must be filename safe, for all platforms. */ protected String createDigest(final String source) { final DigestEngine digestEngine = DigestEngine.sha256(); final byte[] bytes = digestEngine.digest(CharUtil.toSimpleByteArray(source)); String digest = Base32.encode(bytes); if (uniqueDigestKey != null) { digest += uniqueDigestKey; } return digest; }