/** * 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); }
/** * Encrypts a block. */ @Override public byte[] encryptBlock(final byte[] content, final int offset) { long[] contentBlock = bytesToLongs(content, offset, blockSizeInBytes); long[] encryptedBlock = new long[blockSize / Long.SIZE]; blockEncrypt(contentBlock, encryptedBlock); return longsToBytes(encryptedBlock); }
@Override public byte[] decryptBlock(final byte[] encryptedContent, final int offset) { long[] encryptedBlock = bytesToLongs(encryptedContent, offset, blockSizeInBytes); long[] decryptedBlock= new long[encryptedBlock.length]; blockDecrypt(encryptedBlock, decryptedBlock); return longsToBytes(decryptedBlock); }
/** * 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); }
/** * Generate a salt for use with the BCrypt.hashpw() method, * selecting a reasonable default for the number of hashing * rounds to apply. * * @return an encoded salt value */ public static String gensalt() { return gensalt(GENSALT_DEFAULT_LOG2_ROUNDS); }
@Override public boolean check(final String input, final String hash) { return BCrypt.checkpw(input, hash); } };
@Override public String hash(final String input) { return BCrypt.hashpw(input, salt); }
/** * Creates new SHA-1 digest. */ public static DigestEngine sha1() { return new JavaDigestEngine("SHA-1"); } /**
@Override public boolean check(final String input, final String hash) { return pbkdf2Hash.validatePassword(input, hash); } };
@Override public String decryptString(final byte[] encryptedContent) { return threefish.decryptString(encryptedContent); } };
@Override public byte[] encryptString(final String input) { return threefish.encryptString(input); }
@Override public String hash(final String input) { return pbkdf2Hash.createHash(input); }
public static long hashCode(final long k0, final long k1, final byte[] data) { return hash24(k0, k1, data); }
/** * Creates new SHA-384 digest. */ public static DigestEngine sha384() { return new JavaDigestEngine("SHA-384"); } /**
/** * Creates new MD2 digest. */ public static DigestEngine md2() { return new JavaDigestEngine("MD2"); } /**
/** * Creates new SHA-256 digest. */ public static DigestEngine sha256() { return new JavaDigestEngine("SHA-256"); } /**
/** * Creates new MD5 digest. */ public static DigestEngine md5() { return new JavaDigestEngine("MD5"); } /**
/** * Creates new SHA-512 digest. */ public static DigestEngine sha512() { return new JavaDigestEngine("SHA-512"); }