the code #include <iostream> #include <cryptopp/rsa.h> #include <cryptopp/filters.h> #include <cryptopp/osrng.h> #include <cryptopp/sha.h> #include <cryptopp/hex.h>
int main() { // Generate RSA keys with 2048 bits CryptoPP::AutoSeededRandomPool rng; CryptoPP::RSA::PrivateKey privateKey; privateKey.GenerateRandomWithKeySize(rng, 2048); CryptoPP::RSA::PublicKey publicKey; publicKey.AssignFrom(privateKey); // Message std::string message = "secret"; // Encrypt with OAEP padding CryptoPP::RSAES_OAEP_SHA_Encryptor encryptor(publicKey); std::string encrypted; CryptoPP::StringSource(message, true, new CryptoPP::PK_EncryptorFilter(rng, encryptor, new CryptoPP::StringSink(encrypted) ) ); // Decrypt CryptoPP::RSAES_OAEP_SHA_Decryptor decryptor(privateKey); std::string decrypted; CryptoPP::StringSource(encrypted, true, new CryptoPP::PK_DecryptorFilter(rng, decryptor, new CryptoPP::StringSink(decrypted) ) ); // Print results std::cout << "Original message: " << message << std::endl; std::cout << "Encrypted message (hex): "; CryptoPP::StringSource(encrypted, true, new CryptoPP::HexEncoder( new CryptoPP::FileSink(std::cout) ) ); std::cout << std::endl; std::cout << "Decrypted message: " << decrypted << std::endl; return 0; } Jeffrey Walton <noloa...@gmail.com> schrieb am Di. 16. Apr. 2024 um 21:19: > > > On Tue, Apr 16, 2024 at 1:44 PM One Sini <ones...@gmail.com> wrote: > >> I wasn't entirely satisfied with the security, so I've adjusted the code. >> I'm not sure if that helps you, depending on what you're doing with it. >> >> This code uses RSA with OAEP (Optimal Asymmetric Encryption Padding) to >> avoid security issues like padding oracle attacks. It generates RSA keys >> with a length of 2048 bits, encrypts the message with OAEP padding, and >> then decrypts it. >> >> Best Regards Satoshi >> > > I deleted the message from the group. The *.pdf and *.pages smells of > malware. > > If you want to provide code, please inline it or provide it as a text > attachment. > > Jeff > >> -- > 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-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8%3DwptAsfC1eM0Up37oZt14dok_C3R%3DqLiwSrbUJHiVNSw%40mail.gmail.com > <https://groups.google.com/d/msgid/cryptopp-users/CAH8yC8%3DwptAsfC1eM0Up37oZt14dok_C3R%3DqLiwSrbUJHiVNSw%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- 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-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/cryptopp-users/CAJm61-BxHt2h1D3abpygLrW4ayDxsnTdBEjzB4yftfrM9k7eHQ%40mail.gmail.com.