encrypt()
encrypt(\Gishiki\Security\Encryption\Asymmetric\PrivateKey $key, string $message) : string
Encrypt the given message using the given private key.
You will need the public key to decrypt the encrypted content.
You can decrypt an encrypted content with the decrypt() function.
An example of usage can be:
$default_privkey = new PrivateKey();
$encrypted_message = Cryptography::encrypt($default_privkey, "this is my important message from my beloved half");
echo "Take good care of this and give it to my GF: " . $encrypted_message;
Parameters
\Gishiki\Security\Encryption\Asymmetric\PrivateKey | $key | the private key to be used to encrypt the plain message |
string | $message | the message to be encrypted |
Throws
- \InvalidArgumentException
the plain message is not a string
- \Gishiki\Security\Encryption\Asymmetric\AsymmetricException
an error occurred while encrypting the given message
Returns
string —the encrypted message