Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 584807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T14:56:11+00:00 2026-05-13T14:56:11+00:00

Grails 1.1 onwards has ‘encodeAsMD5’ available on Strings — is there a way to

  • 0

Grails 1.1 onwards has ‘encodeAsMD5’ available on Strings — is there a way to provide a salt for the function?

Typical usage:

${myString.encodeAsMD5()}

Another option would be to use the Apache DigestUtils class.

I’m not using this to do password hashing — instead, I’m using it for a verification mechanism to determine when a request was created and how much time elapsed when the response was received.

To start out, I encrypt the date/time of when a request was initially created and pass it over to the client. Later when the client sends some data back, it includes the original hash value which is then used in determining how much time has passed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T14:56:12+00:00Added an answer on May 13, 2026 at 2:56 pm

    Are you wanting to have a salt because you’re trying to do password hashing? If so, please consider jBCrypt, a secure, really easy-to-use, password hashing library. You can probably easily hook it in as a Groovy string metamethod. 😛

    And if you’re not doing password hashing, I’m not sure where a salt would come in; please feel free to elaborate in that case. 🙂


    Example of how to use HMAC to do keyed hashing (I used HmacMD5 in my example, but you can use HmacSHA1, HmacSHA256, HmacSHA384, or HmacSHA512 also):

    import javax.crypto.Mac;
    import javax.crypto.spec.SecretKeySpec;
    
    public byte[] hmacMD5(byte[] key, byte[] data) {
        Mac mac = Mac.getInstance("HmacMD5");
        mac.init(new SecretKeySpec(key, "HmacMD5"));
        mac.update(data);
        return mac.doFinal();
    }
    

    I’m sorry that this is in Java and not Groovy, but hopefully it’ll be easy enough for you to adapt. 🙂 Anyway, in this example, your constant value would be the key, and the incoming data would be the data.

    If your data is sizeable (unlikely from what you’ve described), you can call update multiple times, and the hash would work as though the data from those calls were all concatenated together.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.