I presume it's that way so it could be extended with custom algorithms, but wouldn't it be more convenient to apply, let's say, factory method pattern here and avoid the whole NoSuchAlgorithmException
thing?
Something like:
MessageDigest.getMD5Algorithm();
or
MessageDigest.getInstance(DigestAlgorithmFactory.getMD5Algorithm())
I'm guessing there's a bigger picture here, but I just can't see it.
MessageDigest.getMD5Algorithm();
then the class would have to be updated everytime it needed to support a new algorithm, and there are a lot of algorithms. – Qwerky Jan 4 at 12:14