• 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

Decryption code for 3DES

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Java Cowboy
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 16084
88
Android Scala IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic