-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: Encrypting a field in hibernate.
PostPosted: Sun Apr 02, 2006 8:10 am 
Newbie

Joined: Tue Mar 28, 2006 8:41 pm
Posts: 1
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp

Hibernate version: 3.0.5

Name and version of the database you are using: postgreSQL 8.1

I am looking at hibernate to do a billing/transaction program. It looks great so far, but I am confused as to how to tell hibernate (postgreSQL) to encrypt entries. I would need this for storing credit card numbers, names, etc.

Is there some easy way to do this that I have just missed when going through the documentation?

Thanks.


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 02, 2006 8:38 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Not usre it belong to the app layer, but you can write a UserType doing the job

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Apr 02, 2006 11:57 am 
Newbie

Joined: Fri Mar 31, 2006 8:49 am
Posts: 4
Location: NL
You can do this easily outside Hibernate. In a previous Spring/Hibernate project, I used a one way encryption method to store encrypted passwords in the database.

So:
1. encrypt the field
2. store the encrypted field (with the other data)

if you need to match data with the encrypted data you just :
1. encrypt the field to be matched,
2. get the (encrypted) field from the database
3. compare both encrypted values.

this works fine if you do not need the original data after storing them in the database (just for matching purposes). I used the same encryption Unix uses to store passwords (Java code can be found for free - ask me if you need help).

If you do need the original (decrypted) data after storing them in the database, you need an encryption algorithm that works 2 ways (so you can decrypt too). Google will help you get this code also...

This is not really a Hibernate solution but it will do the job without too much effort (took me a few hours) to build.

good luck,
erik


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.