Hasher cleanup and simplification
This commit is contained in:
parent
27f212f3ec
commit
1dfe3d962f
@ -59,9 +59,10 @@ public class Hasher {
|
|||||||
// specified in the constructor. This will return a cached value
|
// specified in the constructor. This will return a cached value
|
||||||
// on subsequent invocations. Returns the empty string on failure.
|
// on subsequent invocations. Returns the empty string on failure.
|
||||||
public String getHash() {
|
public String getHash() {
|
||||||
if (hashCache != null)
|
if (hashCache != null) {
|
||||||
return hashCache;
|
return hashCache;
|
||||||
else if (file != null) {
|
}
|
||||||
|
if (file != null) {
|
||||||
byte[] buffer = new byte[1024];
|
byte[] buffer = new byte[1024];
|
||||||
int read;
|
int read;
|
||||||
InputStream input = null;
|
InputStream input = null;
|
||||||
@ -85,9 +86,12 @@ public class Hasher {
|
|||||||
// returning true if they are equal. The empty string and null are
|
// returning true if they are equal. The empty string and null are
|
||||||
// considered non-matching.
|
// considered non-matching.
|
||||||
public boolean match(String otherHash) {
|
public boolean match(String otherHash) {
|
||||||
if (hashCache == null) getHash();
|
if (otherHash == null) {
|
||||||
if (otherHash == null || hashCache.equals(""))
|
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
if (hashCache == null) {
|
||||||
|
getHash();
|
||||||
|
}
|
||||||
return hashCache.equals(otherHash.toLowerCase(Locale.ENGLISH));
|
return hashCache.equals(otherHash.toLowerCase(Locale.ENGLISH));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user