File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Decryption code for 3DES

 
Ravi Seshu
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Viewer, I have a problem decrypting a 3DES encrypted string. Can any one has a way to decrypt a 3des encrypted string. say for ex: " {3DES}SKbZpRTcR8urG/viVJL1Hw== " can you please provide any info how to do it in java any sample code..as i find many blogs java code doesnot support unsigned keyword so, it cant do decryption, by the way its 168 bit long...etc.. can any one help me in this regard, how to decrypt a 3des string? -rawse
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello "Rawse", first of all, have a look at the official naming policy of JavaRanch and please change your display name accordingly. Especially note the following: All JavaRanch users are asked to use a real name as their display name, with a first and last name, and maybe more, separated by spaces.

Now to your question:

"...as i find many blogs java code doesnot support unsigned keyword so, it cant do decryption..."

You have misunderstood what is described in those blogs. The "unsigned" keyword as it exists in the C and C++ programming languages does not have anything to do with cryptography or digital signatures. The fact that Java does not have the "unsigned" keyword does not have anything to do with whether you can do cryptography with Java.

To find out how to decrypt triple DES data with Java, use Google to search for "java triple des decryption". Here's an example.
 
Henry Wong
author
Marshal
Pie
Posts: 20834
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Rawse",

The JavaRanch system shows that you have been warned at least three times already. Please correct your screen name prior to your next post, or your account may be suspended.

Can any one has a way to decrypt a 3des encrypted string. say for ex: " {3DES}SKbZpRTcR8urG/viVJL1Hw== " can you please provide any info how to do it in java any sample code


First of all, this isn't pure triple DES. Triple DES output is binary data -- not ASCII text. From the "==" ending, I would guess that the binary data has also been Base64 encoded.

Now, I am going to get disagreement here... but you can use the sun.misc.BASE64Decoder class to decode the text back to binary data. (I'll let someone else recommend an external package that is supported)

Once you have the binary data, you can decrypt it with a triple DES cypher. You can get it via...



Also notice that you will need to know what the triple DES key is. This is the equivalent to a password. It is a byte array of length 24. And you will need to know what it is.


One last point, I am only assuming that it is a triple DES follow by a base 64 encode. You need to know exactly how it is encrypted, so you can reverse the process. The triple DES algorithm built into core Java is an "ede". If the process uses an external package, with a different triple DES technique, you will need to use that external package to decrypt.

Henry
[ March 08, 2007: Message edited by: Henry Wong ]
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Henry: "Now, I am going to get disagreement here... but you can use the sun.misc.BASE64Decoder class to decode the text back to binary data. (I'll let someone else recommend an external package that is supported)"

Yes. The sun.misc.BASE64Decoder class is an internal Sun class that will not work if you are using something else than Sun's JVM. You should not use it. Get a library like Apache Jakarta Commons Codec for an officially supported Base64 decoder.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic