Page 1 of 1

3Des encript and decrypt

Posted: Fri Jul 20, 2018 7:50 am
by naresh
Hello Sir,
Can any one help me 3des encryption and after encryption what was the encrypted data length and how to decrypt it.
Thanks,
Thammineni Naresh

Re: 3Des encript and decrypt

Posted: Mon Jul 23, 2018 5:37 am
by happy123654
the input data for 3DES encryption is divided into many blocks and every block has the fixed length: 64bit = 8bytes.
If the last block does not match the length, we need to pad this block, which make the block to be 64bit.
the padding mode have the followed:

public static final byte PAD_ISO9796
public static final byte PAD_ISO9796_MR
public static final byte PAD_ISO9797_1_M1_ALG3
public static final byte PAD_ISO9797_1_M2_ALG3
public static final byte PAD_ISO9797_M1
public static final byte PAD_ISO9797_M2
public static final byte PAD_NOPAD

If the last block is not 64bit and the padding mode is PAD_NOPAD, this will result in fail.

The input data for 3DES decryption must have the length of the multiple of 64bit and the input data is the cipher text.
COS decrypt the cipher text and unpad the result.

If you want to find the theory of the 3DES encryption and decryption. you can search it on the net.