C/C#实现RSA签名

本文详细介绍了如何使用C和C#语言分别实现RSA数字签名的过程。通过实例展示了对1进行签名的步骤,并提供了签名后的结果。讨论了在C与C#中进行RSA签名的具体实现细节。
摘要由CSDN通过智能技术生成

先是对1的数字签名

using System.IO;
using System.Security.Cryptography;  

static void Main(string[] args)
        {
            HashAlgorithm hash = HashAlgorithm.Create();
            byte[] hashBytes = hash.ComputeHash(Encoding.UTF8.GetBytes("1"));
            //The   value   to   hold   the   signed   value.   
            byte[] SignedHashValue;
            //Generate   a   public/private   key   pair.   
            RSACryptoServiceProvider RSA = new  RSACryptoServiceProvider();

            //Create   an   RSAPKCS1SignatureFormatter   object   and   pass   it   the     
            //RSACryptoServiceProvider   to   transfer   the   private   key.   
            RSAPKCS1SignatureFormatter RSAFormatter = new RSAPKCS1SignatureFormatter(RSA);
            //Set   the   hash   algorithm   to   SHA1.   
            RSAFormatter.SetHashAlgorithm("SHA1");
            //Create   a   signature   for   HashValue   and
  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值