【发布时间】:2011-11-15 01:02:58
【问题描述】:
我正在尝试做一件非常简单的事情,即使用 64 位密码和 64 位明文(均为十六进制)并使用简单的旧 DES 对其进行加密。
我的脚本如下所示:
plaintext=`echo -n "$2" | sed 's/\(..\)/\\\x\1/g'`
key=$1
printf "$plaintext" | openssl enc -nosalt -e -des -nopad -K "$key" -iv "0000000000000000" | od --format=x1 --width=32 --address-radix=n | sed 's/ //g'
我执行并得到以下结果:
./des_enc 5B5A57676A56676E 675A69675E5A6B5A
b617e2c84a4fba2149dd7132433031392257b99d9284b1031c351c15825aca52
问题是从 openssl 返回的数据太多,我希望只获得 64 位数据而不是 512。我不知道如何显式请求 64 位版本的 DES,甚至可能吗?
注意:以上使用的值来自“H. Katzan, The Standard Data Encryption Algorithm, pp75-94, Petrocelli Books Inc., New York, 1977”:
Key: 5B5A57676A56676E
Plaintext: 675A69675E5A6B5A
Ciphertext: 974AFFBF86022D1F
【问题讨论】:
标签: bash encryption openssl