The extension method org.codehaus.groovy.runtime.EncodingGroovyMethods#digest(byte, java.lang.String) produces erroneous hashes for all hash functions not having 128-bits length when the resulting hash starts with 0.
This is due to padding the resulting string with zeroes to 32 chars length. 32 chars are only valid for 128 bit hash functions like md5. The padding should applied differently depending on the length of the digest returned.
Of the MessageDigest built-in hash functions this affects SHA-1 and SHA-256 at least.
Solution would be to use getDigestLength() or the length of the returned digest and add some proper unit tests.
Example of erroneous hashes: