常用技巧
如何编写一个二进制规律性的文件, 比如你可以编写一个"0123456789abcdef"的文本文件,记得删除换行符然后用ultraedit打开,ctrl+H就可以看到二进制文件,对应的0x30 0x31 0x32…或者使用xxd -i 1.txt查看

AES
openssl enc -aes-128-cbc -in mingwen.data -K 000102030405060708090A0B0C0D0E0F -iv a0a1a2a3a4a5a6a7a8a9aAaBaCaDaEaF -out miwen.data

openssl aes-128-cbc -d -in miwen.data -K 000102030405060708090A0B0C0D0E0F -iv a0a1a2a3a4a5a6a7a8a9aAaBaCaDaEaF -out mingwen.data

RSA
产生公私**对
openssl genrsa -out test_priv.pem 2048
openssl rsa -pubout -in test_priv.pem -out test_pub.pem

公钥加密、私钥解密
openssl rsautl -encrypt -in hello -inkey test_pub.key -pubin -out hello.en
openssl rsautl -decrypt -in hello.en -inkey test_priv.key -out hello.de

私钥签名、公钥验签
openssl dgst -sign test_priv.pem -sha256 -out sign.txt file.txt
openssl dgst -verify test_pub.pem -sha256 -signature sign.txt file.txt

公钥中提取N和E
1、openssl rsa -inform PEM -in Key0_pub.pem -pubin -text -out Key1_pub.txt
2、或使用网页:https://the-x.cn/base64

HMAC
1、openssl dgst -hmac hmackey -sha256 -out out.hash in.data
2、或者在线计算: https://1024tools.com/hmac

openssl命令行的使用

相关文章: