This class provides the functionality of a secret (symmetric) key generator.
and
are you having trouble understanding? You can consult Wikipedia if you don't believe me.
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
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![Triple Des Key Generator Java Triple Des Key Generator Java](/uploads/1/2/5/7/125758638/386008016.jpg)
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![Triple des key generator java code Triple des key generator java code](/uploads/1/2/5/7/125758638/729340659.jpg)
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
Key generators are constructed using one of the
getInstance
class methods of this class. KeyGenerator objects are reusable, i.e., after a key has been generated, the same KeyGenerator object can be re-used to generate further keys.
Data Encryption Standard (DES) is one of the symmetric encryption algorithms that allows both parties, sender and receiver, to use same key to encrypt and decrypt data. DES was developed by IBM in 1975. It is considered as an insecure algorithm due to its key size 56 bits and block size 64 bits. However, it successor, Triple DES (3DES) is secure.
Imports System.Security.Cryptography Imports System.Text Imports System.IO Module TripleDESSample Sub Main Try ' Create a new TripleDES object to generate a key ' and initialization vector (IV). Specify one ' of the recognized simple names for this ' algorithm. It is common for the 1st and 3rd keys to be the same (i.e. By taking a double length, 16-byte, key you re-use the first component as the 3rd component). To use a triple length key just skip the bit above where the 1st component (bytes 0 - 7) is copied into the space for the 3rd (bytes 16 - 23).
There are two ways to generate a key: in an algorithm-independent manner, and in an algorithm-specific manner. The only difference between the two is the initialization of the object:
- Algorithm-Independent InitializationAll key generators share the concepts of a keysize and a source of randomness. There is an
init
method in this KeyGenerator class that takes these two universally shared types of arguments. There is also one that takes just akeysize
argument, and uses the SecureRandom implementation of the highest-priority installed provider as the source of randomness (or a system-provided source of randomness if none of the installed providers supply a SecureRandom implementation), and one that takes just a source of randomness.Since no other parameters are specified when you call the above algorithm-independentinit
methods, it is up to the provider what to do about the algorithm-specific parameters (if any) to be associated with each of the keys. - Algorithm-Specific InitializationFor situations where a set of algorithm-specific parameters already exists, there are two
init
methods that have anAlgorithmParameterSpec
argument. One also has aSecureRandom
argument, while the other uses the SecureRandom implementation of the highest-priority installed provider as the source of randomness (or a system-provided source of randomness if none of the installed providers supply a SecureRandom implementation).
In case the client does not explicitly initialize the KeyGenerator (via a call to an
init
method), each provider must supply (and document) a default initialization. Every implementation of the Java platform is required to support the following standard
KeyGenerator
algorithms with the keysizes in parentheses: - AES (128)
- DES (56)
- DESede (168)
- HmacSHA1
- HmacSHA256
Greenhorn
posted 11 years agoHi 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
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
Rancher
posted 11 years agoTripleDES 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'.
Greenhorn
posted 11 years agoHi 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
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
Rancher
posted 11 years agoThat'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.
Greenhorn
posted 11 years agoHi 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
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
Rancher
posted 11 years agoWith DES and TripleDES you don't specify the key length, because they're fixed. See my first post.
Greenhorn
posted 11 years agoHi 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
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
Triple Des Key Generator Java Download
Rancher
posted 11 years agoWhich 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.
author
posted 11 years agoElangeswaran 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...
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)
Greenhorn
posted 11 years agoTriple Des Key Generator Java Pdf
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
Rancher
posted 11 years agoI 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).
![Triple Des Key Generator Java Triple Des Key Generator Java](/uploads/1/2/5/7/125758638/386008016.jpg)
Sheriff
posted 11 years agoBlowfish 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 - OCEJPAD 6
How To Ask QuestionsHow To Answer Questions
How To Ask QuestionsHow To Answer Questions
Greenhorn
posted 11 years agoHi 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
Ranch Hand
posted 11 years agoThe 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.
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.
author
posted 11 years ago![Triple des key generator java code Triple des key generator java code](/uploads/1/2/5/7/125758638/729340659.jpg)
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
Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)