Groovy web console

subscribe to the feed Subscribe
to this
site
Simple MD5 hash encryption (via #groovywebconsole)
tweet this snippet Tweet
this
script

Simple MD5 hash encryption

Published 3 weeks ago by ICI with tags hash encryption md5
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
import java.security.MessageDigest
import java.security.NoSuchAlgorithmException

def md5 = ''
def input = 'excacc.MRUSR0018'

try {
    MessageDigest digest = MessageDigest.getInstance('MD5')
    digest.update(input.bytes, 0, input.length())
    md5 = new BigInteger(1, digest.digest()).toString(16)
} catch (NoSuchAlgorithmException e) {
    log.error('Error creating MD5 hash', e)
}

println md5