在c#中使用PEM文件中的私钥加密字符串 [英] Encrypt string with private key from PEM file in c#

查看:628
本文介绍了在c#中使用PEM文件中的私钥加密字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个存储在PEM文件中的私钥(类似于----- BEGIN RSA PRIVATE KEY -----

MIICWw ........... ....... XoA == ----- END RSA私钥-----)。现在我需要使用该私钥和SHA1对给定的字符串进行加密,然后使用base 64对其进行编码。我正在谷歌上搜索没有结果的日子......

I have a private key stored in a PEM file (something like -----BEGIN RSA PRIVATE KEY-----
MIICWw.................. XoA==-----END RSA PRIVATE KEY-----). Now I need to encrypt a given string using that private key and SHA1 and then encode that using base 64. I’m googling for days with no results…

推荐答案

你知道你需要两个密钥:一个加密,另一个解密?!为什么?这就是重点。



从这里开始: http:/ /en.wikipedia.org/wiki/Public-key_cryptography [ ^ ]。



RSA?请仔细阅读: http://msdn.microsoft.com/en-us/library /system.security.cryptography.rsa.aspx [ ^ ]。



-SA
Did you know that you need two keys: one encrypts, another decrypts?! Why? This is the whole point.

Start here: http://en.wikipedia.org/wiki/Public-key_cryptography[^].

RSA? See carefully: http://msdn.microsoft.com/en-us/library/system.security.cryptography.rsa.aspx[^].

—SA


这篇关于在c#中使用PEM文件中的私钥加密字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆