wood burning stoves 2.0*
The moose likes Other JSE/JEE APIs and the fly likes Triple DES encrytpion and decryption  using 256 bit and 512 bit Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Triple DES encrytpion and decryption  using 256 bit and 512 bit " Watch "Triple DES encrytpion and decryption  using 256 bit and 512 bit " New topic
Author

Triple DES encrytpion and decryption using 256 bit and 512 bit

Elangeswaran kangaraj
Greenhorn

Joined: Jan 04, 2009
Posts: 12
Hi All,

I am new to 3DES algorithm with encryption and decryption. I want to know how we encrypt and decrypt a data based on the key with 256 and 512 bit format using Triple DES (3DES). I want Code sample for the above concept.

I need this sharing in soon....

I expect your valuable reply in soon.

Thanks int Advance,
K.Elanges
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
TripleDES does not use those key sizes. It uses 168 bit (DES uses 56 bit, and TripleDES uses 3 times that - hence its name). An example of using DES can be found here. Using TripleDES instead would involved replacing the "DES" cipher designation by "DESede".


Ping & DNS - my free Android networking tools app
Elangeswaran kangaraj
Greenhorn

Joined: Jan 04, 2009
Posts: 12
Hi All,

I am new to 3DES , thats why i asking this question. kindly send the code sample for 3DES to key based encryption and decryption with specified bit key length.

Thanks in advance...

Regards
K.Elanges
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
That's not how JavaRanch works. Instead of writing the code for you, we try to help you write the code yourself. But -if you look at the link I posted- there's hardly anything left to write. Just change the cipher designator accordingly, and you're done. If you're unsure about what that entails I suggest that you read up on JCE (the Java API for encryption) so you understand what's going on. It's easy to get encryption wrong (and thus insecure) if one doesn't understand what's happening underneath; start here.
Elangeswaran kangaraj
Greenhorn

Joined: Jan 04, 2009
Posts: 12
Hi Ulf Dittmer

i have done the following for 3DES. But i want to know how we specify key bit length for encryption and decryption.




Your valuable ideas will be very help to me.
Thanks in advance.
Regards,
L.Elanges
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
With DES and TripleDES you don't specify the key length, because they're fixed. See my first post.
Elangeswaran kangaraj
Greenhorn

Joined: Jan 04, 2009
Posts: 12
Hi Ulf Dittmer,

Thanks for your quick reply. I want to use Triple DES and key length should be following 16,32,64,128,256 and 512. Bit value may be we read from a properties files.

Kindly tell me how we implement...

Thanks in Advance.

Regards,
K.Elanges
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
Which part of
TripleDES does not use those key sizes. It uses 168 bit (DES uses 56 bit, and TripleDES uses 3 times that - hence its name).

and
With DES and TripleDES you don't specify the key length, because they're fixed.

are you having trouble understanding? You can consult Wikipedia if you don't believe me.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18546
    
  40

Elangeswaran kangaraj wrote:
Thanks for your quick reply. I want to use Triple DES and key length should be following 16,32,64,128,256 and 512. Bit value may be we read from a properties files.

Kindly tell me how we implement...


As Ulf mentioned, TripleDES uses 168 bit keys. With the Java implementation, this is spread out over 24 bytes. So... if you want to have the key lengths, that you can specify, you will have to create a way to convert those key lengths to 24 bytes. This is not specific to 3DES, you will have to invent something yourself -- maybe you can send the bits to a hashing algorithm (like SHA1) and take the 24 bytes from that?

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Elangeswaran kangaraj
Greenhorn

Joined: Jan 04, 2009
Posts: 12

Hi Ulf Dittmer,

I have hope with you. can you share with me other than 3DES algorithm how we encrypt a data based on a static key with specified bit size. Assume the bit size is available in a properties file.

I expect you favorable reply. If you provide code for that it would be very helpful to me.

Thanks in advance.

Regards,
K.Elanges
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41177
    
  45
I don't know how else to say that what you're asking is impossible. You need to read up on how DES and TripleDES work. It's dangerous to use encryption without understanding how it works (meaning it's easy to implement something that's not really secure).
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19656
    
  18

Blowfish can have a key of up to 448 bits, and is supported by the javax.crypto package.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Elangeswaran kangaraj
Greenhorn

Joined: Jan 04, 2009
Posts: 12

Hi Ulf Dittmer.

I understand your suggestions and all. If we could not use 3DES with key size as 256 or 512 bit means there are any other algorithms for this requirement that is my intention. So, I asked with you.... Kindly suggestion me...

Thanks in advance.

Rgards,
K.Elanges
Carey Evans
Ranch Hand

Joined: May 27, 2008
Posts: 225

The supported encryption algorithms for Sun Java are listed in the Sun Providers Documention, including the supported key lengths. If you don't want to use standard algorithms like 3DES or AES with restricted key sizes, you could choose Blowfish or RC4.

Bear in mind that RC4 is remarkably easy to use insecurely, as in the WEP protocol. In addition, RC2 was designed so that the NSA could break it 20 years ago if it used 40 bit keys, and any algorithm using keys shorter than 128 bits is going to be fairly vulnerable today.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 18546
    
  40



Also keep in mind that algorithms are not equal -- ie. key lengths are not equal. Meaning a 256 bit key length with one algorithm may be as secure as a 1024 bit key length with another algorithm. It is kinda silly to pick an algorithm purely for it's support of a particular key length.

Henry

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Triple DES encrytpion and decryption using 256 bit and 512 bit
 
Similar Threads
how to encrypt the text
Any implementation of Javascript Encryption and Java Decryption of Triple DES Algorithm
BadPaddingException with DES
Java Encrypt and decrypt using Open SSL
168 bit 3DES encryption and decryption....