I'm looking for two functions conceptually similar to these:
// returns the encrypted text
string encrypt( string public_key, string pass_phrase, string text );
// returns the original text
string decrypt( string private_key, string pass_phrase, string encrypted_text );
where string
could be a char*
, a std::string
or something easily convertible to those two. And where public_key
and private_key
can be basically anything, from keys generated with some commands (gpg/ssl stuff or whatever), to keys generated with other simple functions.
I've looked into a few cryptography libraries (libgcrypt, libgpgme, openssl ...), but it doesn't look easy at all to implement such functions with those libraries: they require a non-superficial knowledge about asymmetric encryption and a lot of code.
Anyway this task doesn't seem uncommon. How can I implement the two functions above?