• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

encryption and decryption required

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello ,
I need help regarding encryption and decryption .

I need to do the following :
1 >
User will ente some text

2 >
Encrypt this text and store in database

3 >
while retrieving data - decrypt and display to user


My environment is JDK1.3 and I am using Dynamo

Could someone guide me with some examples as to how I could encrypt simple string data and store in database and conversely decrypt and display data .

My limited knowledge tells me that MD5 can be only used for encryption - not decryption

I also tried some examples from googling related to - "DES"
However when I try to run the examples - I get this error -
"java.lang.ExceptionInInitializerError: java.lang.SecurityException: Cannot set up certs for trusted CAs: java.lang.SecurityException: Cannot locate policy and/or framework files for signer restraint check!
at javax.crypto.SunJCE_b.<clinit>(DashoA6275)
at javax.crypto.KeyGenerator.getInstance(DashoA6275)"

I am sure I am missing something very very basic .

Any help would be greatly appreciated.

Thanks in advance,
-anagha
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're right, MD5 is a hash, which is kind of a one-way encryption. There's no easy way to get the original text back out of it.

Here's an introductory article on how to encrypt/decrypt something using JCE.
 
pendse anagha
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Ulf for your suggestion .

Please bear with me since some of the questions may sound vague and inappropriate.
My lack of basics related to JCE and the need to do an implementation of JCE
is driving me nuts .

OK : here goes with a few more of my doubts :

I am using JDK1.3
I tried using the "DES" algorithm

I could get it running by adding "jce1_2_2.jar" & "sunjce_provider.jar" in my classpath
Here is a link which provided me with information about setting up JCE for 1.2.x flavour of JDK :
Security

To get it running -
1 >option 1 - add the following line :


2 >The other option is - add this line in my Java code :


Here are my observations :
If I dont do either of the above configuration ( for SunJCE Provider ) then I get a run time exception java.security.NoSuchAlgorithmException: Algorithm DES not available

So my questions / doubts / inferences are :

1 >DES is not supported by the other providers : sun.security.provider.Sunand com.sun.rsajca.Provider

2 >So what kind of algorithms are supported by either sun.security.provider.SunOR com.sun.rsajca.Provider ?

3 >I am and will be using JDK1.3
So are there any examples of algorithms that are supported by the providers mentioned above ?


4 >If I wanted to use SunJCE provider - is it better to add the provider through code or in the java.security file ?
What are the advantages or disadvantages in the above method ?


4 >Could someone point me to some examples which use the above providers ?

5 >I tried looking into JDK1.3 - I am not able to locate the classes with the correct Package structure ?
So I am not sure if these are classes that need to be implemented by some third party ?

Totally confused.

Any help is greatly appreciated .

Regards ,
-anagha
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JCE was not part of JDK 1.3, so you need to add it explicitly, but you seem to have figured that out. A good starting point for learning about JCE is this page. It is part of the JDK 1.4 docs, but I don't think anything substantial changed from the add-on versions for JDK 1.2/1.3. Appendix A in particular talks about which ciphers are available, and there are code examples as well.
[ November 24, 2005: Message edited by: Ulf Dittmer ]
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I had the same issue with Java 1.5 (on Windows 2008 / 64), "Cannot locate policy and/or framework files ". I got the policy strength files from Oracle, then unzipped them into the C:\Java64\jdk1.5.0_22\jre\lib\security directory. However, the ZIP file had a path of "jce" for the policy JAR files, and so unzipping them placed them at: C:\Java64\jdk1.5.0_22\jre\lib\security\jce. Even though I put that entry in the Path environment variable, they were still not found. I copied them up one level, to C:\Java64\jdk1.5.0_22\jre\lib\security, and then my Java program worked and performed 256 bit encryption / decryption, so it obviously found the files.

Greg Burdett
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Greg Burdett wrote:I had the same issue with Java 1.5 (on Windows 2008 / 64), "Cannot locate policy and/or framework files ". I got the policy strength files from Oracle, then unzipped them into the C:\Java64\jdk1.5.0_22\jre\lib\security directory. However, the ZIP file had a path of "jce" for the policy JAR files, and so unzipping them placed them at: C:\Java64\jdk1.5.0_22\jre\lib\security\jce. Even though I put that entry in the Path environment variable, they were still not found. I copied them up one level, to C:\Java64\jdk1.5.0_22\jre\lib\security, and then my Java program worked and performed 256 bit encryption / decryption, so it obviously found the files.

Greg Burdett



You're responding to an almost 6 year old question? Really?
 
reply
    Bookmark Topic Watch Topic
  • New Topic