If you are encrypting to send to the other side, then you want to do something like Diffie Hellman or ECDH key exchange to establish a shared secret. If you just want to encrypt for storage, you need a secure random number generator. I do not believe M2Crypto provides this?
It looks like M2Crypto supports Diffie Hellman.
source
share