Implementation of the RSA public key encryption algorithm.
Methods
Class constructor
__construct(\Zend\Crypt\PublicKey\RsaOptions $options)
Decrypt with private/public key
decrypt(string $data, \Zend\Crypt\PublicKey\Rsa\AbstractKey $key, int $mode) : string
$data can be encoded in base64 or not. $mode sets how the input must be processed:
- MODE_AUTO: Check if the $signature is encoded in base64. Not recommended for performance.
- MODE_BASE64: Decode $data using base64 algorithm.
- MODE_RAW: $data is not encoded.
see |
\Zend\Crypt\PublicKey\Rsa::MODE_AUTO |
see |
\Zend\Crypt\PublicKey\Rsa::MODE_BASE64 |
see |
\Zend\Crypt\PublicKey\Rsa::MODE_RAW |
Parameters
$data
string
Exceptions
Returns
string
Encrypt with private/public key
encrypt(string $data, \Zend\Crypt\PublicKey\Rsa\AbstractKey $key) : string
Parameters
$data
string
Exceptions
Returns
string
RSA instance factory
factory(array | \Traversable $options) : \Zend\Crypt\PublicKey\Rsa
Parameters
$options
array\Traversable
Exceptions
Returns
Generate new private/public key pair
generateKeys(array $opensslConfig) : \Zend\Crypt\PublicKey\Rsa
see |
\Zend\Crypt\PublicKey\RsaOptions::generateKeys() |
Parameters
$opensslConfig
array
Exceptions
Returns
Return last openssl error(s)
getOpensslErrorString() : string
Sign with private key
sign(string $data, \Zend\Crypt\PublicKey\Rsa\PrivateKey $privateKey) : string
Parameters
$data
string
Exceptions
Returns
string
Verify signature with public key
verify(string $data, string $signature, \Zend\Crypt\PublicKey\Rsa\PublicKey $publicKey, int $mode) : bool
$signature can be encoded in base64 or not. $mode sets how the input must be processed:
- MODE_AUTO: Check if the $signature is encoded in base64. Not recommended for performance.
- MODE_BASE64: Decode $signature using base64 algorithm.
- MODE_RAW: $signature is not encoded.
see |
\Zend\Crypt\PublicKey\Rsa::MODE_AUTO |
see |
\Zend\Crypt\PublicKey\Rsa::MODE_BASE64 |
see |
\Zend\Crypt\PublicKey\Rsa::MODE_RAW |
Parameters
$data
string
$signature
string
Exceptions
Returns
bool
Properties
Constants