/** * Creates SHA-256 digest of a file. * * @param file {@link File} to create digest of. * @return SHA-256 digest of the {@link File}. */ public static String sha256(final File file) throws IOException { return DigestEngine.sha256().digestString(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; }
/** * Creates MD5 digest of a {@link File}. * * @param file {@link File} to create digest of. * @return MD5 digest of the {@link File}. */ public static String md5(final File file) throws IOException { return DigestEngine.md5().digestString(file); }
/** * Creates SHA-512 digest of a file. * * @param file {@link File} to create digest of. * @return SHA-512 digest of the {@link File}. */ public static String sha512(final File file) throws IOException { return DigestEngine.sha512().digestString(file); }
/** * Returns string hash of input string. */ public default String digestString(final String input) { return StringUtil.toHexString(digest(input)); }
@Test void testSha1() { assertEquals("626B0566A836677FA85C6952417E704E727E336C", DigestEngine.sha1().digestString("Jodd")); }
/** * Returns digest of a file. Implementations may not read the whole * file into the memory. */ public byte[] digest(final File file) throws IOException;
@Test void testSha512() { assertEquals("ACF65B0C3DE891B2984F461FA12EF4DD205B2DE360F3C834A47368CBDD334687AB5E8405AA910DF8AC6B5631BF1F2CC5133B0D95493A40452EC5B984E4FC31E8", DigestEngine.sha512().digestString("Jodd")); }
@Test void testSha256() { assertEquals("D5E94A2DD851E6E2A233EFA00CF26B385A933F26223B00757E189397F8B92530", DigestEngine.sha256().digestString("Jodd")); }
/** * 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)); }
/** * Creates SHA-512 digest of a file. * * @param file {@link File} to create digest of. * @return SHA-512 digest of the {@link File}. */ public static String sha512(final File file) throws IOException { return DigestEngine.sha512().digestString(file); }
@Test void testMD5() { assertEquals("5513A194A0D3E46B8D90021B283BE791", DigestEngine.md5().digestString("Jodd")); } }
/** * Creates SHA-256 digest of a file. * * @param file {@link File} to create digest of. * @return SHA-256 digest of the {@link File}. */ public static String sha256(final File file) throws IOException { return DigestEngine.sha256().digestString(file); }
public default String digestString(final File file) throws IOException { return StringUtil.toHexString(digest(file)); }
/** * Creates MD5 digest of a {@link File}. * * @param file {@link File} to create digest of. * @return MD5 digest of the {@link File}. */ public static String md5(final File file) throws IOException { return DigestEngine.md5().digestString(file); }
/** * 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)); }