Open GoogleCodeExporter opened 9 years ago
For byte[]:
import java.security.MessageDigest;
import org.bouncycastle.util.encoders.Hex;
def bytes2path = { bytes ->
def digest = MessageDigest.getInstance('md5')
def checksum = new String(Hex.encode(digest.digest(bytes)))
def path = checksum.split(/(?<=\G.{2})/) as List
path << checksum
}
byte[] bytes = new File('src/main/groovy/bytes.groovy').bytes
println bytes2path(bytes)
Original comment by benfortuna
on 29 Nov 2011 at 11:20
Original issue reported on code.google.com by
benfortuna
on 29 Nov 2011 at 2:50