void rsaEncode()
{
////////////////////////////////////////////////
// Generate keys
AutoSeededRandomPool rng;
InvertibleRSAFunction params;
params.GenerateRandomWithKeySize( rng, 1536 );
RSA::PrivateKey privateKey( params );
RSA::PublicKey publicKey( params );
string plain="RSA Encryption", cipher, recovered;
////////////////////////////////////////////////
// Encryption
RSAES_OAEP_SHA_Encryptor e( publicKey );
StringSource ss1( plain, true,
new PK_EncryptorFilter( rng, e,
new StringSink( cipher )
) // PK_EncryptorFilter
); // StringSource
cout << cipher << endl;
////////////////////////////////////////////////
// Decryption
RSAES_OAEP_SHA_Decryptor d( privateKey );
StringSource ss2( cipher, true,
new PK_DecryptorFilter( rng, d,
new StringSink( recovered )
) // PK_DecryptorFilter
); // StringSource
assert( plain == recovered );
cout << recovered << endl;
system("pause");
}
I must ask how could it be possible to create RSA keys then write them to file, then read them as a string and use them in the following code...
I've seen what you are talking about, but I am talking about RSA that works like the following AES.
void EEencode (string data,string Skey)
{
byte key[16];
byte iv[16];
string bin;
string theKey(Skey);
int i(0);
theKey.append("t;rke;tlrke65409654ytr");
while(i != 16)
{
key[i] = theKey[i];
iv[i] = theKey[i];
i++;
}
// Encryptor
CryptoPP::ECB_Mode< CryptoPP::AES >::Encryption
//Encryptor( key, sizeof(key), iv );
Encryptor( key, sizeof(key));
// Encryption
CryptoPP::StringSource( data, true,
new CryptoPP::StreamTransformationFilter( Encryptor,
new CryptoPP::StringSink( MTbuffer )
) // StreamTransformationFilter
); // StringSource
}--
--
You received this message because you are subscribed to the "Crypto++ Users" Google Group.
To unsubscribe, send an email to cryptopp-user...@googlegroups.com.
More information about Crypto++ and this group is available at http://www.cryptopp.com.
---
You received this message because you are subscribed to the Google Groups "Crypto++ Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cryptopp-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.