I'm looking for an asymmetric encryption library for php that can generate keys, hand out public keys and decrypt incoming messages with the corresponding private key. However, I'm a novice in the field of encryption and while googling for a usable library, I always come across all these functions that take tons of arguments of which I have no idea what they are for and how they work.

What I basically need is 3 functions like this :

  • list($public_key, $private_key) = generate_random_keys(); //Generate a pair of keys that I put in a database. Then hand out the public key to a certain user.

  • $encrypted_message = encrypt($message, $public_key); //Encrypt a message to a user with the public key associated with that user.

  • $decrypted_message = decrypt($encrypted_message, $private_key); //Decrypt an incoming message from a user with the private key associated with that user.

Does anyone know a simple library for that, that doesn't need all kinds of extra parameters that need to be in all kinds of formats that aren't clear to people who have no experience in these things?

  • 1
    What's wrong with openssl bindings ? they seem to provide what you want... – b0fh Aug 5 '10 at 15:08

Check out OpenSSL and GnuPG for PHP

(I can't post more than one hyperlink so search for GnuPG on the PHP site to get more info)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy