MessageDigest takes a string for what algorithm to use when you're about to hash. I've used some of the code here to accumulate a rather large list of 220 "algorithms" on my android device. I iterated through all of them using them as an algorithm in MessageDigest and very few of them actually produce a hash.
How can I, at runtime, determine what hashes MessageDigest will produce an output for without trying every one?
List the Services of each provider, then call the getType() method. If it is MessageDigest, then this is a hash algorithm. Something like:
Provider[] providers = Security.getProviders();
for (Provider p : providers) {
String providerStr = String.format("%s/%s/%f\n", p.getName(),
p.getInfo(), p.getVersion());
Set<Service> services = p.getServices();
for (Service s : services) {
if ("MessageDigest".equals(s.getType())) {
System.out.printf("\t%s/%s/%s", s.getType(),
s.getAlgorithm(), s.getClassName());
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With