crypto ++ RSA加密字符串示例 [英] crypto++ RSA encrypt string example

查看:395
本文介绍了crypto ++ RSA加密字符串示例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道如何使用crypto ++ rsa加密字符串?crypto ++示例只有encrpt文件,我想用自定义修复公钥和私钥加密字符串。

例如:



string publicKey =abc;

string privateKey =123;

string message =要加密的文字;

string encyptedString = encypt(publicKey,message);



decrypt(privateKey,encyptedString)



问题花了我太多时间,帮助!!!!

解决方案

这不是RSA的工作原理,而不是公钥加密的工作原理。关键不是任意数据。即使它是这样,也不是以下显而易见的:如果一个密钥是任意的,密钥对中的第二个密钥以某种方式与另一个密钥相关? :-)



首先,您真的需要了解公钥加密的工作原理。请参阅:

http://en.wikipedia.org/wiki/Public-key_cryptography [ ^ ](非常明确的解释,必读对于每个开发人员),

http://en.wikipedia.org/wiki/RSA_ %28algorithm%29 [ ^ ] 。



至于Crypto ++实现,文档很容易找到:

http://www.cryptopp.com/wiki/RSA_Cryptography#Keys [ ^ ],

http: //www.cryptopp.com/wiki/Main_Page [ ^ ]。



最后的注释:如果你说这个简单的问题费用我太多的时间,这是一个麻烦的迹象,但你需要它来继续学习和获得经验。所有这些问题都应该快速解决,因为它们只是使用了一些非常常见的API,而不是创造新的东西。



-SA

Has anyone know how to encrypt string with crypto++ rsa?The crypto++ sample has just encrpt file,I want to encrypt a string with custom fix public key and private key.
for example like this:

string publicKey ="abc";
string privateKey = "123";
string message = "text to encrypt";
string encyptedString = encypt(publicKey, message);

decrypt(privateKey, encyptedString)

The problem cost me too much time,help!!!!

解决方案

This is not how RSA works, and not how public-key cryptography works. The key is never an arbitrary piece of data. Even if it was so, isn't the following obvious: if one key is arbitrary, the second of the keys in the key pair is somehow related to the other key? :-)

First of all, you really need to understand how public-key cryptography works. Please see:
http://en.wikipedia.org/wiki/Public-key_cryptography[^] (very clear explanation, must-read for every developer),
http://en.wikipedia.org/wiki/RSA_%28algorithm%29[^].

As to Crypto++ implementation, the documentation is quite easy to find:
http://www.cryptopp.com/wiki/RSA_Cryptography#Keys[^],
http://www.cryptopp.com/wiki/Main_Page[^].

The final note: if you say that this simple problem "cost me too much time", this is troublesome sign, but all you need it to keep learning and getting experience. All such problems should be resolved quickly, as they are reduced to just using some very usual API, not creating something new.

—SA


这篇关于crypto ++ RSA加密字符串示例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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