资源简介
具体描述参考 https://blog.csdn.net/iamqianrenzhan/article/details/88583822

代码片段和文件信息
//#include “D:\cryptopp562\randpool.h“
//#include “D:\cryptopp562\rsa.h“
//#include “D:\cryptopp562\hex.h“
//#include “D:\cryptopp562\files.h“
//#include “D:\cryptopp562\osrng.h“
//#include “D:\cryptopp562\base64.h“
#include “randpool.h“
#include “rsa.h“
#include “hex.h“
#include “files.h“
#include “osrng.h“
#include “base64.h“
#include
using namespace CryptoPP;
using namespace std;
//根据长度生成公钥和私钥,并分别保存到pubFilename文件和privFilename文件
void GenerateRSAKey(unsigned int keyLength const char *privFilename const char *pubFilename)
{
AutoSeededRandomPool rng;
InvertibleRSAFunction privkey;
privkey.GenerateRandomWithKeySize(rng keyLength);
base64Encoder privkeysink(new FileSink(privFilename)); //“privkey.txt“
privkey.DEREncode(privkeysink);
privkeysink.MessageEnd();
RSAFunction pubkey(privkey);
base64Encoder pubkeysink(new FileSink(pubFilename)); //“pubkey.txt“
pubkey.DEREncode(pubkeysink);
pubkeysink.MessageEnd();
}
//把字符串plain中的内容用pubFilename文件中的公钥加密数据并保存到encryptedFilename中。
void Encrypt(const string &plain const char *pubFilename const char *encryptedFilename)
{
RSAES_OAEP_SHA_Encryptor pubkey(FileSource(pubFilename true new base64Decoder));
SecByteBlock sbbCipherText(pubkey.CiphertextLength(plain.size()));
//sbbCipherText.begin();
AutoSeededRandomPool rng;
pubkey.Encrypt(
rng
(byte const*)plain.data()
plain.size()
sbbCipherText.begin());
FileSink(encryptedFilename).Put(sbbCipherText.begin() sbbCipherText.size());
}
void Encrypt2(const string &plainconst char *encryptedFilename)
{
//RSAES_OAEP_SHA_Encryptor pubkey(FileSource(pubFilename true new base64Decoder));
string pub = “MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQC1f+WV5dAiVb2w1lgf21Wz84Uuou1TwCJ+\
ivxcpijobsHQLOLMakYSyRonH6SQJtL5CHXycBubA9sS7F2nVG2fMn6z9Ev11nu7J4IPPF9u\
v / ZqwAIlXwxVPsl4K69rWmdP4i5ezj++I7nC + kX6qjxpcyhnQalKAl2OC8AMNEo0awIBEQ == “;
RSAES_OAEP_SHA_Encryptor pubkey(StringSource(pub true new base64Decoder));
SecByteBlock sbbCipherText(pubkey.CiphertextLength(plain.size()));
//sbbCipherText.begin();
AutoSeededRandomPool rng;
pubkey.Encrypt(
rng
(byte const*)plain.data()
plain.size()
sbbCipherText.begin());
FileSink(encryptedFilename).Put(sbbCipherText.begin() sbbCipherText.size());
}
//用privFilename文件中的私钥解密encryptedFilename文件中的加密内容,并返回解密内容。
string Decrypt(const char *privFilename const char *encryptedFilename)
{
string strContents recovered;
FileSource(encryptedFilename true new StringSink(strContents));
AutoSeededRandomPool rng;
RSAES_OAEP_SHA_Decryptor privkey(FileSource(privFilename true new base64Decoder));
StringSource(strContents true new PK_DecryptorFilter(rng privkey new StringSink(recovered)));
return recovered;
}
string Decrypt2(const char *encryptedFilename)
{
string pri = “MIICdAIBADANBgkqhkiG9w0BAQEFAASCAl4wggJaAgEAAoGBALV/5ZXl0CJVvbDWWB/bVbPz\
hS6i7VPAIn6K / FymKOhuwdAs4sxqRhLJG
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
..A..H. 39936 2019-03-16 16:34 RSA\.vs\RSA\v14\.suo
文件 7164 2019-03-19 01:50 RSA\RSA\main.cpp
文件 6488 2019-03-16 10:09 RSA\RSA\RSA.vcxproj
文件 1246 2019-03-15 09:38 RSA\RSA\RSA.vcxproj.filters
文件 1294 2019-03-14 23:31 RSA\RSA\RSATools.cpp
文件 795 2019-03-14 23:24 RSA\RSA\RSATools.h
文件 1774 2019-03-16 00:43 RSA\RSA\test.cpp
文件 1291 2019-03-14 22:15 RSA\RSA.sln
目录 0 2019-03-14 22:15 RSA\.vs\RSA\v14
目录 0 2019-03-14 22:15 RSA\.vs\RSA
...D.H. 0 2019-03-14 22:15 RSA\.vs
目录 0 2019-03-24 06:55 RSA\RSA
目录 0 2019-03-24 06:55 RSA
----------- --------- ---------- ----- ----
59988 13
相关资源
- The direction of synaptic plasticity mediated
- C 大整数RSA加密
- DXperienceUniversal 10.1.6(2010年8月13日版
- RSA算法源码
- RSA AES DES ECC加密算法源码
- 提供几个加密算法的源码
- 易语言RSA加解密源码
- Anti-biofilm Activity of Resveratrol and Ursol
- 联想K29最新1.70BIOS修改版,去白名单验
- IBM Rational Software Architect 9.0破解文件
- Universal Extractor(万能文件解包工具)
- DXperienceUniversal-11.1.7.part06
- DXperienceUniversal-11.1.7.part08
- DXperienceUniversal-11.1.7.part14
- DXperienceUniversal-11.1.7.part15
- DXperienceUniversal-11.1.7.part10
- DXperienceUniversal-11.1.7.part13
- DXperienceUniversal-11.1.7.part03
- DXperienceUniversal-11.1.7.part02
- DXperienceUniversal-11.1.7.part09
- DXperienceUniversal-11.1.7.part19
- DXperienceUniversal-11.1.7.part12
- DXperienceUniversal-11.1.7.part18
- DXperienceUniversal-11.1.7.part16
- DXperienceUniversal-11.1.7.part20
- DXperienceUniversal-11.1.7.part07
- DXperienceUniversal-11.1.7.part17
- DXperienceUniversal-11.1.7.part04
- IBM 2U Universal Tape Autoloader产品手册
- IBM 4U Universal Tape Library产品手册
评论
共有 条评论