What will be the most efficient way (optimal for performance and storage space) to store the MD5 sum of file in a java (or groovy) object considering the following use-cases:
- I need to compare with thousands of other md5 sums.
- I may need to store this in HSQLDB, so that records can be pulled/
group bybased on md5 - May be stored in
Map‘s as keys
I am trying to avoid storing it as String as String comparisons will be more costly and take more space. Will BigInteger(string,radix) be more efficient? Also, what datatype should be selected if persisting in database?
Create a class that wraps a
byte[]and provides no mutation. If you want to use it as a key in a map, then it needs to either be comparable, or have a hash code. With abyte[]you’ll have an easier time computing a simple hashcode from the first 32 bits.