mirror of
https://github.com/packwiz/packwiz-installer.git
synced 2025-05-11 06:56:31 +02:00
Fix case-sensitivity for standard hashes, add more hash support
This commit is contained in:
parent
ca4a13589d
commit
b314fc8e0b
@ -4,9 +4,9 @@ import okio.HashingSource;
|
|||||||
import okio.Source;
|
import okio.Source;
|
||||||
|
|
||||||
public class HashingSourceHasher implements IHasher {
|
public class HashingSourceHasher implements IHasher {
|
||||||
String type;
|
private String type;
|
||||||
|
|
||||||
public HashingSourceHasher(String type) {
|
HashingSourceHasher(String type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -15,7 +15,7 @@ public class HashingSourceHasher implements IHasher {
|
|||||||
HashingSource delegateHashing;
|
HashingSource delegateHashing;
|
||||||
HashingSourceHash value;
|
HashingSourceHash value;
|
||||||
|
|
||||||
public HashingSourceGeneralHashingSource(HashingSource delegate) {
|
HashingSourceGeneralHashingSource(HashingSource delegate) {
|
||||||
super(delegate);
|
super(delegate);
|
||||||
delegateHashing = delegate;
|
delegateHashing = delegate;
|
||||||
}
|
}
|
||||||
@ -46,7 +46,7 @@ public class HashingSourceHasher implements IHasher {
|
|||||||
}
|
}
|
||||||
HashingSourceHash objHash = (HashingSourceHash) obj;
|
HashingSourceHash objHash = (HashingSourceHash) obj;
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
return value.equals(objHash.value);
|
return value.equalsIgnoreCase(objHash.value);
|
||||||
} else {
|
} else {
|
||||||
return objHash.value == null;
|
return objHash.value == null;
|
||||||
}
|
}
|
||||||
@ -71,9 +71,12 @@ public class HashingSourceHasher implements IHasher {
|
|||||||
@Override
|
@Override
|
||||||
public GeneralHashingSource getHashingSource(Source delegate) {
|
public GeneralHashingSource getHashingSource(Source delegate) {
|
||||||
switch (type) {
|
switch (type) {
|
||||||
|
case "md5":
|
||||||
|
return new HashingSourceGeneralHashingSource(HashingSource.md5(delegate));
|
||||||
case "sha256":
|
case "sha256":
|
||||||
return new HashingSourceGeneralHashingSource(HashingSource.sha256(delegate));
|
return new HashingSourceGeneralHashingSource(HashingSource.sha256(delegate));
|
||||||
// TODO: support other hash types
|
case "sha512":
|
||||||
|
return new HashingSourceGeneralHashingSource(HashingSource.sha512(delegate));
|
||||||
}
|
}
|
||||||
throw new RuntimeException("Invalid hash type provided");
|
throw new RuntimeException("Invalid hash type provided");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user