aspose file tools*
The moose likes Java in General and the fly likes Decryption code for 3DES Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Decryption code for 3DES" Watch "Decryption code for 3DES" New topic
Author

Decryption code for 3DES

Ravi Seshu
Ranch Hand

Joined: Mar 19, 2005
Posts: 38
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

Joined: Aug 16, 2005
Posts: 14272
    
  21

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18896
    
  40

"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 ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14272
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Decryption code for 3DES