I don't understand why you are using this approach but you are encrypting with the random key and then decrypting with the key generated from the password! You must must must use the same key for decryption as encryption.
P.S. Why are you not using Password Based Encryption (PBE)?
PP.S. A DES key is 56 bits normally packaged as 8 bytes with the least significant bit of each byte being a parity bit. This means that your code
is flawed since the key is neither 16 bits or even 16 bytes.
Retired horse trader.
Note: double-underline links may be advertisements automatically added by this site and are probably not endorsed by me.
Joined: Jan 07, 2011
Thank you for the reply.
the requirement I have is not to use PBE, i have checked this option
I will change the key to 56 bits. and any tips on getting the decryption right will be of great help to me - Thanks