使用字符串加密RSA(C ++) [英] Encrypt RSA using string (C++)

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

问题描述

我不知道如何将 int value 转换为 string 消息,该消息可以使用公式使用 int 值!!如何直接使用( int或long数据类型)加密(字符串数据类型)消息。如果使用那些具有 long数据类型值的代码,它只是喜欢计算数学值 ...而且......希望能够将值解密回原始消息。 。 谢谢!!请帮忙!



删除紧急程度[/ edit]

I don't know how to convert the int value to string message which can be encoded using formula in which the formula is using the int or long value!! how to encrypt(string data type) message instead direct using (int or long data type). if using those code with long datatype value, it just like calculate a mathematics value...And also... hopefully can decrypt the value back to the original message ... thank you!! Please Help!

[edit]removed urgency[/edit]

推荐答案

因为这是Windows,您可以使用Win32加密API: http:// msdn .microsoft.com / zh-CN / library / Windows / desktop / aa380255%28v = vs.85%29.aspx [ ^ ]。



此CodeProject文章可能很有用:使用Win32加密API进行加密 [ ^ ]。



如果您更喜欢某些开源实现,我会理解。在Google代码中查看此代码: https://code.google.com/p/rsa/ [ ^ ]。



你可以找到更多: http://bit.ly/17DtcEg [ ^ ]。



最后,您可以根据描述从头开始实施RSA算法。如果你从这里开始,你可以找到所有内容: http://en.wikipedia.org/wiki/RSA_%28algorithm%29 [ ^ ]。



-SA
As this is Windows, you can use Win32 Crypto API: http://msdn.microsoft.com/en-us/library/Windows/desktop/aa380255%28v=vs.85%29.aspx[^].

This CodeProject article could be useful: Encryption using the Win32 Crypto API[^].

I would understand if you prefer some open-source implementation. Look at this one at Google code: https://code.google.com/p/rsa/[^].

You can find some more: http://bit.ly/17DtcEg[^].

Finally, you can implement RSA from scratch based on description of the algorithm. You can find everything if you start here: http://en.wikipedia.org/wiki/RSA_%28algorithm%29[^].

—SA


让我直截了当,因为看起来你对加密很新。



你可以加密文本数据或二进制数据,比如int或long int变量,或者那些数组,或者带有混合文本和二进制文件的结构数据。加密算法并不关心,它只占用一定数量的字节并将它们加密到另一个缓冲区中(通常)相同数量的字节。



所以如果你有一个要加密的int值,则不需要先将它转换为字符串值。



至于如何将加密算法应用于任意的字节缓冲区,谢尔盖的解决方案给了你很多提示。您可以通过Google找到许多示例。
Just let me get some things straight, as it looks you are rather new to encryption.

You can encrypt both, text data or binary data, like an int or long int variable, or an array of those, or a structure with mixed text and binary data. The encryption algorithm does not care, it just take a certain number of bytes and encrypts them into (most often) the same number of bytes in a another buffer.

So if you have an int value that you want to encrypt, there is no need to convert it first to a string value.

As for how to apply encryption algorithms to an arbitrary buffer of bytes, the solution of Sergey has given you lots of hints. And there are many examples around that you can find via Google.


尝试 http://www.stringencrypt。 com / [ ^ ]它可以帮助您加密字符串并生成所选编程语言中的解密代码。
Try http://www.stringencrypt.com/[^] it helps you to encrypt the string and generates the decryption code in selected programming language.


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

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