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 572145
In Process

The Archive Base Latest Questions

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

I’m working on a Grails 1.0.4 project that has to be released in less

  • 0

I’m working on a Grails 1.0.4 project that has to be released in less than 2 weeks, and the customer just came up with a requirement that all data in the database should be encrypted.

Since encryption of every database access in the application itself could take a lot of time and will be error prone, the solution I seek is some kind of encryption transparent to the application.

Is there a way to setup Hibernate to encrypt all data in all tables (except maybie the id and version columns) or should I seek a MySQL solution (we’re using MySQL 5.0) ?

EDIT:
Thanks for all of your posts for alternative solutions, if the customer changes mind it would be great. As for now, the requirement is “No plain text in the Database”.

Second thing I’d like to point out is that I’m using Grails, for those not fammiliar with it, It’s a convention over configuration, so even small changes to the application that are not by convention should be avoided.

  • 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-13T13:34:56+00:00Added an answer on May 13, 2026 at 1:34 pm

    Well it has been a long time since I’ve asked the question. In the meantime, thanks for all the answers. They were great when dealing with the original idea of encrypting the entire database, but the requirement changed to only encrypting sensitive user info, like name and address. So the solution was something like the code down below.

    We’ve implemented an Encrypter which reads the encryption method from the record ( so there can be different encryption per record) and use it to connect transient duplicate fields to the ones encrypted in the database. The added bonus/drawbacks are:

    • The data is also encrypted in memory, so every access to the method getFirstName descrypts the data (I guess there is a way to cache decrypted data, but I dont need it in this case)
    • Encrypted fields cannot be used with default grails/hibernate methods for search through database, we’ve made custom methods in services that get data, encrypt it and then use the encrypted data in the where clause of a query. It’s easy when using User.withCriteria

      class User {

      byte[] encryptedFirstName
      byte[] encryptedLastName
      byte[] encryptedAddress
      
      Date dateCreated // automatically set date/time when created
      Date lastUpdated // automatically set date/time when last updated
      
      EncryptionMethod encryptionMethod = ConfigurationHolder.config.encryption.method
      
      def encrypter = Util.encrypter
      
      static transients = [ 
      'firstName', 
      'lastName', 
      'address',
      'encrypter'
      ]
      
      static final Integer BLOB_SIZE = 1024
      
      static constraints = {
      
          encryptedFirstName maxSize: BLOB_SIZE, nullable: false
          encryptedLastName maxSize: BLOB_SIZE, nullable: false
      
          encryptedAddress maxSize: BLOB_SIZE, nullable: true
      
          encryptionMethod nullable: false
      
      } // constraints
      
      String getFirstName(){
          decrypt('encryptedFirstName')
      }
      
      void setFirstName(String item){     
          encrypt('encryptedFirstName',item)
      }
      
      String getLastName(){
          decrypt('encryptedLastName')
      }
      
      void setLastName(String item){
          encrypt('encryptedLastName',item)       
      }
      
      String getAddress(){
          decrypt('encryptedAddress')
      }
      
      void setAddress(String item){
          encrypt('encryptedAddress',item)        
      }
      
      byte[] encrypt(String name, String value) {
      
          if( null == value ) {
              log.debug "null string to encrypt for '$name', returning null"
              this.@"$name" = null
              return
          }
      
          def bytes = value.getBytes(encrypter.ENCODING_CHARSET)
          def method = getEncryptionMethod()
      
      
          byte[] res 
      
          try {
              res = encrypter.encrypt( bytes, method )            
          } catch(e) {
              log.warn "Problem encrypting '$name' data: '$string'", e
          }
      
          log.trace "Encrypting '$name' with '$method' -> '${res?.size()}' bytes"
      
          this.@"$name" = res
      
      }
      
      String decrypt(String name) {
      
          if(null == this.@"$name") {
              log.debug "null bytes to decrypt for '$name', returning null"
              return null
          }
      
          def res 
          def method = getEncryptionMethod()
      
          try {
              res = new String(encrypter.decrypt(this.@"$name", method), encrypter.ENCODING_CHARSET )
          } catch(e) {
              log.error "Problem decrypting '$name'", e
          }
      
          log.trace "Decrypting '$name' with '$method' -> '${res?.size()}' bytes"
      
          return res
      }
      

      }

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a French site that I want to parse, but am running into

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.