Triple DES encryption with MD5 hashkey

Anyone worked on this type of encryption. Please help.

The following parameters should be used as part of the encryption process.
Key Size : 164 bytes
Block Size : 128 bytes
Key : generated dynamically

I m getting the following error:
Key is suppose to be 164 bytes. but DESede key requires 24 bytes.
 Not sure where is the error. Please help

Exception in thread "main" java.security.InvalidKeyException: Wrong key size
      at javax.crypto.spec.DESedeKeySpec.<init>(DashoA12275)
      at javax.crypto.spec.DESedeKeySpec.<init>(DashoA12275)
     

(Edited by _alias99)
import org.apache.commons.codec.b
inary.*;
import java.security.spec.AlgorithmParameterSpec; 
 
public class Multiply{
private long expireTimeInMilliseconds;
 
        public static void main(String[] args) throws Exception {
               
 
                String s = integerObj + "0";
                integerObj = Integer.parseInt(s);
 
               if(args.length != 2){
                                                System.out.println("Usage: java Multiply <rows> <columns>");
                                                System.exit(0);
                                                }
                                                int rows = 0, columns = 0;
                                                try{
                                                rows = Integer.parseInt(args[0]);
                                                columns = Integer.parseInt(args[1]);
                                                }catch(NumberFormatException e){
                                                System.out.println("Wrong parameter(s)");
                                                System.exit(0);
                                                }
                                                System.out.println("Multiplication Table ("+rows+" X "+columns+")");
                                                for(int i = 1;i <= rows;i++){
                                                System.out.print(i+"\t>");
                                                for(int j = 1;j <= columns;j++)
                                                System.out.print("\t"+(i*j));
                                                System.out.println("");
        }
 
    public void setExpireTimeInDays(int expireTimeInDays)
{
   expireTimeInMilliseconds = ((long) expireTimeInDays) * 24 * 60 * 60 * 1000;
}

Open in new window

hameedsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
>> Hash code MD5 generates how many bytes?

16. You've another question open on this still?
0
hameedsAuthor Commented:
I think I have resolved a part of it. This is different issue.  i get  another issue with the above code.

Exception in thread "main" java.security.InvalidKeyException: Wrong key size
      at javax.crypto.spec.DESedeKeySpec.<init>(DashoA12275)
      at javax.crypto.spec.DESedeKeySpec.<init>(DashoA12275)
      at TripleDES.main(TripleDES.java:26)

Once I resolve completely, I will accept solution.
0
CEHJCommented:
As you solve parts of the picture you should really be closing the questions as you go along or things tend to get out of hand and can lead to a lack of focus.

Anyway, you should probably be looking into what that .NET code does with the MD5 hash and doing exactly the same
0
Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

objectsCommented:
if you're other question was answered then you wouldn't be having this problem :)

why are you MD5'ing the password to make a key?
you can get thebytes from the key fcatory

    DESedeKeySpec keyspec = (DESedeKeySpec) keyfactory.getKeySpec(key, DESedeKeySpec.class);
    byte[] keyBytes = keyspec.getKey();

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
CEHJCommented:
>>why are you MD5'ing the password to make a key?

Err... because the native code is doing so?

Is that the case hameeds?
0
hameedsAuthor Commented:
Thank you for your support. I  was recently in trouble for posting some  Security Aglorithm which is sensitive and proprietary information. Please REPLACE  the post code snippet with the following code snippet.

import org.apache.commons.codec.binary.*;
import java.security.spec.AlgorithmParameterSpec; 
 
public class Multiply{
private long expireTimeInMilliseconds;
 
        public static void main(String[] args) throws Exception {
               
 
                String s = integerObj + "0";
                integerObj = Integer.parseInt(s);
 
               if(args.length != 2){
								System.out.println("Usage: java Multiply <rows> <columns>");
								System.exit(0);
								}
								int rows = 0, columns = 0;
								try{
								rows = Integer.parseInt(args[0]);
								columns = Integer.parseInt(args[1]);
								}catch(NumberFormatException e){
								System.out.println("Wrong parameter(s)");
								System.exit(0);
								}
								System.out.println("Multiplication Table ("+rows+" X "+columns+")");
								for(int i = 1;i <= rows;i++){
								System.out.print(i+"\t>");
								for(int j = 1;j <= columns;j++)
								System.out.print("\t"+(i*j));
								System.out.println("");
        }
 
    public void setExpireTimeInDays(int expireTimeInDays)
{
   expireTimeInMilliseconds = ((long) expireTimeInDays) * 24 * 60 * 60 * 1000;
}

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.