I need to encrypt/decrypt data using 3DES. the Keys shared with me are in the form of;
Component 1 = 11111111111111111111111111111111
Component 2 = 22222222222222222222222222222222
KVC = ABCD1234
I need to create 3DES Key from the above components, or K1,k2,k3 sub keys,
I understand sub keys are 16 bytes long, however these are 32 bytes long.
Please share the procedure to create 3DES key.
Transform the clear components in to byte arrays using HexStringToByte standard method. Pass the 3 byte arrays to the method below. You can verify your results at http://www.emvlab.org/keyshares/. Here are sample data:
public static byte[] buildKey(byte[] cc1, byte[] cc2, byte[] cc3) {
byte[] result = new byte[cc1.length];
int i = 0;
for (byte b1: cc1) {
byte b2 = cc2[i];
byte b3 = cc3[i];
result[i] = (byte)(b1 ^ b2 ^ b3);
i++;
}
return result;
}