Hy
I hope somebody can help me.
I'm new with crypto++.
I try to encrypt an Message with the private Key of RSA.
My example Code:
to generate Key files:
{
string PrivateKeyFile = "key.pv";
string PublicKeyFile = "key.pb";
AutoSeededRandomPool rng;
int e = 65537;
RSAES_OAEP_SHA_Decryptor Decryptor( rng, 1024 , e );
HexEncoder privFile(new FileSink( PrivateKeyFile.c_str() ));
Decryptor.DEREncode(privFile);
privFile.MessageEnd();
RSAES_OAEP_SHA_Encryptor Encryptor(Decryptor);
HexEncoder pubFile(new FileSink( PublicKeyFile.c_str() ) );
Encryptor.DEREncode(pubFile);
pubFile.MessageEnd();
}
after that ich try to encrypt a message :
{
const char * pubFilename = "key.pv";
FileSource pubFile(pubFilename, true, new HexDecoder);
RSAES_OAEP_SHA_Encryptor pub(pubFile);
AutoSeededRandomPool randPool;
string * result = new string();
StringSource(
message,
true,
new PK_EncryptorFilter(randPool, pub, new HexEncoder(new
StringSink(*result))));
cout << *result << endl;
}
to decrypt the cipher
{
const char * privFilename = "key.pb";
AutoSeededRandomPool randPool;
FileSource privFile(privFilename, true, new HexDecoder);
RSAES_OAEP_SHA_Decryptor priv(privFile);
string *result2 = new string();
StringSource(
cipher,
true,
new HexDecoder(new PK_DecryptorFilter(randPool, priv,
new
StringSink(*result2))));
cout << *result2 << endl;
}
I need this for my bachelor thesis!
Thank a lot
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the "Crypto++ Users"
Google Group.
To unsubscribe, send an email to [EMAIL PROTECTED]
More information about Crypto++ and this group is available at
http://www.cryptopp.com.
-~----------~----~----~----~------~----~------~--~---