Plugins You can find out about all the publicly available Grails plugins.

Digr2iD Codecs

  • Tags: encoding, codec
  • Latest: 1.1
  • Last Updated: 01 January 2010
  • Grails version: 1.0
  • Authors: null
0 vote
compile "org.grails.plugins:digr2id-codecs:1.1"




grails install-plugin digr2id-codecs


Digr2iD Codecs Plugin

This plugin provides a variety of easy-to-use encoders with support of MD2, MD5, SHA-1, SHA-256, SHA-384 and SHA-512 hashing algorithms.

It also adds a tag for the rendering of unencoded strings (e.g. you may need it in case you are using HTML codec as default one but need to render plain-old string without specific encoding).


Below you can see an example of encoding password on user registration in controller using SHA-512:

def do_register = {
    String passwordHash = params.password.encodeAsSha512()

Checking for password match:

def do_login = {
    if (Sha512Codec.match(params.password, passwordHashFromDatabase)) {

Rendering unencoded strings in a GSP

It is a good practice to use HTML as default encoder for you GSPs, but sometimes you need to render some portion of the page without HTML or any other default encoding being applied. <digr2id:raw> tag gives you ability to achieve that. Below you'll find an example of rendering JSON data without default encoding being applied thus allowing JavaScript compile and run smoothly.

var project = <digr2id:raw out="${project as JSON}" />;