常见openssl加解密命令

256 篇文章 3 订阅
22 篇文章 1 订阅
openssl enc -aes-128-cbc -in test.cpp -out test11.cpp -iv f123 -K 1223  #aes-128-cbc为填充模式 -iv指定盐 -K指定秘钥
openssl aes-128-cbc -d -in test11.cpp -out test22.cpp  -iv f123 -K 1223 #解密

sha256sum test.cpp
#控制台输出a4a47eb4777020e741c5b3cd6e29fd2325ebd8c13233095f521009129602ccf3  test.cpp

openssl genrsa -out test_priv.pem 2048 #生成私钥文件test_priv.pem
openssl rsa -pubout -in test_priv.pem -out test_pub.pem #从私钥提取公钥到文件test_pub.pem
openssl dgst -sign test_priv.pem -sha256 -out sign.txt test.cpp #使用杂凑sha256和私钥对test.cpp生成数字签名到文件sig.txt
openssl dgst -verify test_pub.pem -sha256 -signature sign.txt test.cpp #对test.cpp 签名文件sig.txt和公钥test_pub.pem进行验签 控制台输出“Verified OK”表示验证通过


openssl ecparam -list_curves    #查看椭圆曲线
openssl ecparam -name secp256k1 -genkey -out ec.key     #使用椭圆曲线secp256k1生成私钥和参数,写入文件ec.key
openssl ec -in ec.key -pubout -out ec.pubkey    #生成公钥到文件ec.pubkey
openssl dgst -sha256 -sign ec.key -out ec.sig test.cpp  #使用杂凑sha256和私钥对test.cpp生成数字签名到文件ec.sig
openssl dgst -sha256 -verify ec.pubkey -signature ec.sig test.cpp   #对test.cpp 签名文件ec.sig和公钥ec.pubkey进行验签 控制台输出“Verified OK”表示验证通过


openssl genrsa -out test.key 1024  #生成一个1024字节包括公钥和私钥的文件test.key
openssl rsa -in test.key -pubout -out test_pub.key   #从test.key提取公钥到test_pub.key文件
openssl rsautl -encrypt -in test.cpp -inkey test_pub.key -pubin -out test.en #将test.cpp按照公钥加密得到test.en密文
openssl rsautl -decrypt -in test.en -inkey test.key -out test.de #根据私钥将test.en解密为明文test.de
diff test.cpp test.de #两者无差别

openssl version

GitHub - wangzhicheng2013/sm2_utility

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值