Refine search
private static void assertMessageDigestHashing(byte[] input, String algorithmName) { try { MessageDigest digest = MessageDigest.getInstance(algorithmName); assertEquals( HashCode.fromBytes(digest.digest(input)), ALGORITHMS.get(algorithmName).hashBytes(input)); for (int bytes = 4; bytes <= digest.getDigestLength(); bytes++) { assertEquals( HashCode.fromBytes(Arrays.copyOf(digest.digest(input), bytes)), new MessageDigestHashFunction(algorithmName, bytes, algorithmName).hashBytes(input)); } try { int maxSize = digest.getDigestLength(); new MessageDigestHashFunction(algorithmName, maxSize + 1, algorithmName); fail(); } catch (IllegalArgumentException expected) { } } catch (NoSuchAlgorithmException nsae) { throw new AssertionError(nsae); } } }
@Override public Hasher newHasher() { if (supportsClone) { try { return new MessageDigestHasher((MessageDigest) prototype.clone(), bytes); } catch (CloneNotSupportedException e) { // falls through } } return new MessageDigestHasher(getMessageDigest(prototype.getAlgorithm()), bytes); }
MessageDigestHashFunction(String algorithmName, String toString) { this.prototype = getMessageDigest(algorithmName); this.bytes = prototype.getDigestLength(); this.toString = checkNotNull(toString); this.supportsClone = supportsClone(prototype); }
MessageDigestHashFunction(String algorithmName) { this.algorithmName = algorithmName; this.bits = getMessageDigest(algorithmName).getDigestLength() * 8; }
private Object readResolve() { return new MessageDigestHashFunction(algorithmName, bytes, toString); }
@Override public Hasher newHasher() { return new MessageDigestHasher(getMessageDigest(algorithmName)); }
private Object readResolve() { return new MessageDigestHashFunction(algorithmName, bytes, toString); }
private static void assertMessageDigestHashing(byte[] input, String algorithmName) { try { MessageDigest digest = MessageDigest.getInstance(algorithmName); assertEquals( HashCode.fromBytes(digest.digest(input)), ALGORITHMS.get(algorithmName).hashBytes(input)); for (int bytes = 4; bytes <= digest.getDigestLength(); bytes++) { assertEquals( HashCode.fromBytes(Arrays.copyOf(digest.digest(input), bytes)), new MessageDigestHashFunction(algorithmName, bytes, algorithmName).hashBytes(input)); } try { int maxSize = digest.getDigestLength(); new MessageDigestHashFunction(algorithmName, maxSize + 1, algorithmName); fail(); } catch (IllegalArgumentException expected) { } } catch (NoSuchAlgorithmException nsae) { throw new AssertionError(nsae); } } }
@Override public Hasher newHasher() { if (supportsClone) { try { return new MessageDigestHasher((MessageDigest) prototype.clone(), bytes); } catch (CloneNotSupportedException e) { // falls through } } return new MessageDigestHasher(getMessageDigest(prototype.getAlgorithm()), bytes); }
MessageDigestHashFunction(String algorithmName, int bytes, String toString) { this.toString = checkNotNull(toString); this.prototype = getMessageDigest(algorithmName); int maxLength = prototype.getDigestLength(); checkArgument( bytes >= 4 && bytes <= maxLength, "bytes (%s) must be >= 4 and < %s", bytes, maxLength); this.bytes = bytes; this.supportsClone = supportsClone(prototype); }
private Object readResolve() { return new MessageDigestHashFunction(algorithmName, bytes, toString); }
@Override public Hasher newHasher() { if (supportsClone) { try { return new MessageDigestHasher((MessageDigest) prototype.clone(), bytes); } catch (CloneNotSupportedException e) { // falls through } } return new MessageDigestHasher(getMessageDigest(prototype.getAlgorithm()), bytes); }
MessageDigestHashFunction(String algorithmName, String toString) { this.prototype = getMessageDigest(algorithmName); this.bytes = prototype.getDigestLength(); this.toString = checkNotNull(toString); this.supportsClone = supportsClone(prototype); }
private Object readResolve() { return new MessageDigestHashFunction(algorithmName, bytes, toString); }
@Override public Hasher newHasher() { if (supportsClone) { try { return new MessageDigestHasher((MessageDigest) prototype.clone(), bytes); } catch (CloneNotSupportedException e) { // falls through } } return new MessageDigestHasher(getMessageDigest(prototype.getAlgorithm()), bytes); }
MessageDigestHashFunction(String algorithmName, int bytes, String toString) { this.toString = checkNotNull(toString); this.prototype = getMessageDigest(algorithmName); int maxLength = prototype.getDigestLength(); checkArgument( bytes >= 4 && bytes <= maxLength, "bytes (%s) must be >= 4 and < %s", bytes, maxLength); this.bytes = bytes; this.supportsClone = supportsClone(prototype); }
private Object readResolve() { return new MessageDigestHashFunction(algorithmName, bytes, toString); }
@Override public Hasher newHasher() { if (supportsClone) { try { return new MessageDigestHasher((MessageDigest) prototype.clone(), bytes); } catch (CloneNotSupportedException e) { // falls through } } return new MessageDigestHasher(getMessageDigest(prototype.getAlgorithm()), bytes); }
MessageDigestHashFunction(String algorithmName, String toString) { this.prototype = getMessageDigest(algorithmName); this.bytes = prototype.getDigestLength(); this.toString = checkNotNull(toString); this.supportsClone = supportsClone(prototype); }
private Object readResolve() { return new MessageDigestHashFunction(algorithmName, bytes, toString); }