openssl 课上测试2
生成随机数:
点击查看代码
openssl rand -hex 16
点击查看代码
openssl enc -sm4-cbc -in 20211102sn.txt -out sn.enc -K $(xxd -p -c 64 key.bin) -iv $(xxd -p -c 64 iv.bin) -e
点击查看代码
echo '6fc4533c92eed9e2d77f2c7d52eaaef2' | xxd -r -p > iv.bin
点击查看代码
echo '6502526e37a8dab2931340192b3152f6' | xxd -r -p > key.bin
此时iv.bin和key.bin、sn.enc是加密文件不能直接打开,需要输入命令解密
点击查看代码
openssl enc -sm4-cbc -in sn.enc -out decrypted.txt -K $(xxd -p -c 64 key.bin) -iv $(xxd -p -c 64 iv.bin) -d