Poco C++: Poco::Crypto::RSAKey class is deprecated. How to encrypt plain text with private key?

Viewed 49

For a my personal C++ project, I'd like been able to encrypt plain text data using private key. In my project I make an extensive usage of Poco C++ library, and I'd like handle such feature with it.

Currently I am successfully handling a private key file in order to create Poco::Crypto::RSAKey.

std::filesystem::path keyFile = std::filesystem::path("MyFile");
Poco::SharedPtr<Poco::Crypto::RSAKey> key(new Poco::Crypto::RSAKey("", keyFile.string()));
Poco::Crypto::CipherFactory& factory = Poco::Crypto::CipherFactory::defaultFactory();
Poco::Crypto::Cipher* pRSACipher = factory.createCipher(*key.get());
std::string plainText("MyTextToEncrypt");
std::string encrypted =  pRSACipher->encryptString(plainText, Poco::Crypto::Cipher::ENC_BASE64_NO_LF);

Having a look at official Poco documentation I found out that both Poco::Crypto::RSAKey and Poco::Crypto::ECKey are deprecated. Looking for an alternative to such deprecated classes both in Poco documentation and all around in web, I could not understand why such classes are declared as deprecated. Moreover I could not find which classes shouold replace them.

In same time, reading Poco::Crypto::CipherFactory documentation, it is not depracted using methods which get Poco::Crypto::RSAKey for method Poco::Crypto::CipherFactory::createCipher.

Please, can somebody tell me if using Poco::Crypto::RSAKey is still advisable, or another class should be used? And which one?

Thanks in advance!

0 Answers
Related