Make use of the Digest framework of Ruby.
Use [ instead of [[ for portability.
Raise ArgumentError instead of RuntimeError on bad hash length.