@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (getClass() != obj.getClass()) { return false; } int nRes = compareTo((Digest) obj); return nRes == 0; }
@Override public int hashCode() { synchronized (this) { if (h == 0) { h = Objects.hashCode(getAlgorithm()) + getBlockSize(); if (h == 0) { h = 1; } } } return h; }
@Override public final Digest create() { return new BaseDigest(getAlgorithm(), getBlockSize()); }
@Override public void update(byte[] data) throws Exception { update(data, 0, NumberUtils.length(data)); }
@Override public void init() throws Exception { this.md = SecurityUtils.getMessageDigest(getAlgorithm()); }
@Override public final Digest create() { return new BaseDigest(getAlgorithm(), getBlockSize()); }
@Override public void update(byte[] data) throws Exception { update(data, 0, NumberUtils.length(data)); }
@Override public void init() throws Exception { this.md = SecurityUtils.getMessageDigest(getAlgorithm()); }
@Override public int hashCode() { synchronized (this) { if (h == 0) { h = Objects.hashCode(getAlgorithm()) + getBlockSize(); if (h == 0) { h = 1; } } } return h; }
@Override public boolean equals(Object obj) { if (obj == null) { return false; } if (obj == this) { return true; } if (getClass() != obj.getClass()) { return false; } int nRes = compareTo((Digest) obj); return nRes == 0; }
@Override public String toString() { synchronized (this) { if (s == null) { s = getClass().getSimpleName() + "[" + getAlgorithm() + ":" + getBlockSize() + "]"; } } return s; } }
@Override public String toString() { synchronized (this) { if (s == null) { s = getClass().getSimpleName() + "[" + getAlgorithm() + ":" + getBlockSize() + "]"; } } return s; } }
@Override public int compareTo(Digest that) { if (that == null) { return -1; // push null(s) to end } else if (this == that) { return 0; } String thisAlg = getAlgorithm(); String thatAlg = that.getAlgorithm(); int nRes = GenericUtils.safeCompare(thisAlg, thatAlg, false); if (nRes != 0) { return nRes; // debug breakpoint } nRes = Integer.compare(this.getBlockSize(), that.getBlockSize()); if (nRes != 0) { return nRes; // debug breakpoint } return 0; }
@Override public int compareTo(Digest that) { if (that == null) { return -1; // push null(s) to end } else if (this == that) { return 0; } String thisAlg = getAlgorithm(); String thatAlg = that.getAlgorithm(); int nRes = GenericUtils.safeCompare(thisAlg, thatAlg, false); if (nRes != 0) { return nRes; // debug breakpoint } nRes = Integer.compare(this.getBlockSize(), that.getBlockSize()); if (nRes != 0) { return nRes; // debug breakpoint } return 0; }