kas*_*sai 3 encryption 3des tripledes
我需要使用 3DES 加密/解密数据。与我共享的密钥的形式为;
组件 1 = 111111111111111111111111111111111
组件 2 = 22222222222222222222222222222222
KVC = ABCD1234
我需要从上述组件创建 3DES 密钥,或 K1、k2、k3 子密钥,
我知道子键长 16 个字节,但是这些长 32 个字节。
请分享创建 3DES 密钥的过程。
小智 7
使用 HexStringToByte 标准方法将清除组件转换为字节数组。将 3 字节数组传递给下面的方法。您可以在http://www.emvlab.org/keyshares/验证您的结果。以下是示例数据:
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;
}
Run Code Online (Sandbox Code Playgroud)