关于RSACryption帮助类定义见RSACryption

一、加密与解密

            //定义明文和密文变量
string plaintext = "天道酬勤,厚德载物!";
string ciphertext = ""; //产生密钥
string prikey = "", pubkey = "";
rsa.RSAKey(out prikey, out pubkey); //加密解密过程
ciphertext = rsa.RSAEncrypt(pubkey, plaintext);
plaintext = rsa.RSADecrypt(prikey, ciphertext);

二、签名与验证

            //获取明文Hash值
byte[] plaintextHash = null;
rsa.GetHash(plaintext, ref plaintextHash);
//获取签名密文
string SignatureCiphertext = null;
rsa.SignatureFormatter(prikey, plaintextHash, ref SignatureCiphertext);
//验证
string verify = rsa.SignatureDeformatter(pubkey, plaintextHash, SignatureCiphertext) ? "OK!没问题" : "NO!内容被篡改了";

Tips:利用RSA的签名和验证功能还可简单实现软件注册码功能,签名即注册码,验证即验证。

相关链接

RSA分段加密【解决“不正确的长度”的异常】

RSA加密解密与签名验证的更多相关文章

  1. Cryptopp iOS 使用 RSA加密解密和签名验证签名

    Cryptopp 是一个c++写的功能完善的密码学工具,类似于openssl 官网:https://www.cryptopp.com 以下主要演示Cryptopp 在iOS上的RSA加密解密签名与验证 ...

  2. openssl 非对称加密 RSA 加密解密以及签名验证签名

    1. 简介 openssl  rsa.h 提供了密码学中公钥加密体系的一些接口, 本文主要讨论利用rsa.h接口开发以下功能 公钥私钥的生成 公钥加密,私钥解密 私钥加密,公钥解密 签名:私钥签名 验 ...

  3. iOS RSA加密解密及签名验证

    1.首先要下载openssl,这个不用说,直接官网下载或者用brew install openssl下载 2.终端生成私钥密钥 2.1生成私钥 openssl genrsa - 2.2生成密钥 ope ...

  4. iOS RSA 加密解密及签名验证

    1.首先要下载openssl.这个不用说,直接官网下载或者用brew install openssl下载. 2.终端生成私钥密钥. 2.1生成私钥 openssl genrsa - 2.2生成密钥 o ...

  5. RSA加密解密及数字签名Java实现--转

    RSA公钥加密算法是1977年由罗纳德·李维斯特(Ron Rivest).阿迪·萨莫尔(Adi Shamir)和伦纳德·阿德曼(Leonard Adleman)一起提出的.当时他们三人都在麻省理工学院 ...

  6. RSA加密解密和读取公钥、私钥

    /// <summary>     /// RSA加密解密及RSA签名和验证    /// </summary>     public class RSADE    {    ...

  7. RSA加密解密及RSA签名和验证及证书

    RSA加密解密及RSA签名和验证及证书 公钥是给别人的 发送密文使用公钥加密 验证签名使用公钥验证 私钥是自己保留的 接受密文使用私钥解密 发送签名使用私钥签名 上述过程逆转是不行的,比如使用私钥加密 ...

  8. RSA加密解密与加签验签

    RSA公钥加密算法是1977年由罗纳德·李维斯特(Ron Rivest).阿迪·萨莫尔(Adi Shamir)和伦纳德·阿德曼(Leonard Adleman)一起提出的.1987年7月首次在美国公布 ...

  9. C#-java RSA加密解密

    using Org.BouncyCastle.Math; using Org.BouncyCastle.Crypto.Parameters; using Org.BouncyCastle.Securi ...

随机推荐

  1. JS 精度问题处理

    /除法函数,用来得到精确的除法结果 //说明:javascript的除法结果会有误差,在两个浮点数相除的时候会比较明显.这个函数返回较为精确的除法结果. //调用:accDiv(arg1,arg2) ...

  2. 取一种类型里面的产品销售前3甲的数据Sql

    需求:取出每种分类里面的销售前3甲的产品信息 表设计如下图: 数据如下: 两种方法可以实现: 1. SELECT * FROM (SELECT ROW_NUMBER() OVER(PARTITION ...

  3. httppost body的实现, 和body是gb2312等编码的实现

    使用的是http4.X 版本,里面推荐使用的post是key value的形式 List<NameValuePair> formparams = new ArrayList<Name ...

  4. C#邮件收发

    public class Mail { private string mailkey; private string mailSecret; public string mailFrom; publi ...

  5. 在VirtualBox安装OS X 10.10

    下面将指导介绍了如何引入自由和强大VirtualBox安装在虚拟机上OS X Yosemite 10.10 法律免责声明:本指南旨在说明如何在定期购买的苹果电脑上创建一个虚拟机执行真正的Mac OS ...

  6. iWatch # 初始化工程

    iWatch --利用swift,开发iWatch手表小应用! 远程仓库,团队开发: $ git init $ git add . $ git commit -m “ProjectName” // p ...

  7. FindBugs:Compiler output path for module can not be null. check your module/project settings问题原因

    这可能是很多人在使用Android studio 该插件会发现此错误信息:Compiler output path for module can not be null. check your mod ...

  8. IIS 7.5 使用URL Rewrite模块简单设置网页跳转

    原文 IIS 7.5 使用URL Rewrite模块简单设置网页跳转 我们都知道Apache可以在配置文件里方便的设置针对网页或网站的rewrite,但是最近接手了一组IIS服务器,发现这货简单的没有 ...

  9. expected number,sequence,or string.map evaluated instead of freemarker.template.smplehash

    expected number,sequence,or string.map evaluated instead of freemarker.template.smplehash 使用freemark ...

  10. 汤姆大叔 深入理解JavaScript系列(20):《你真懂JavaScript吗?》答案详解 后六道题答案

    原题目地址:http://www.cnblogs.com/TomXu/archive/2012/02/10/2342098.html 答案丰富多彩.我只是记录下自己思考了半天全部的答案. 题目一:找出 ...