美文网首页用户验证与授权
dotnetCore实现RSA的加密解密

dotnetCore实现RSA的加密解密

作者: elef | 来源:发表于2018-12-18 11:57 被阅读40次

本文内容: 采用openssl生成RSA算法需要的私钥、公钥。采用.net core 2.1 控制台应用实现基于RSA算法的加密解密和签名校验。

首先着手搭建一个基于 dotnet core 2.1 的控制台项目

目录位置:E:\github\dotnet\dotnetCore.rsa

  • 安装dotnet core2.1

  • 创建项目

$ dotnet new console -n dotnetCore.rsa -o E:\github\dotnet\dotnetCore.rsa
  • 编写 .gitignore

[Bb]in/
[Oo]bj/

生成私钥公钥

需要下载安装openssl工具包。由于git中就包含该工具包,只要把git程序的user/bin目录加到环境参数 path中,就能直接使用了。我当前win7下目录为:C:\Program Files\Git\usr\bin

生成私钥:

openssl genrsa -out private.key 2048

根据私钥生成公钥:

openssl rsa -in private.key -pubout -out public.key

编写代码

项目截图

源码地址:https://github.com/daijinming/dotnetCore.rsa

相关文章

网友评论

    本文标题:dotnetCore实现RSA的加密解密

    本文链接:https://www.haomeiwen.com/subject/vfwkkqtx.html