SecretBox class
Framework\Crypto\SecretBox
Class SecretBox.
Defined in libraries/crypto/src/SecretBox.php
Properties #
$key
protected string $key
$nonce
protected string $nonce
Methods #
- __construct()
- SecretBox constructor.
- decrypt()
- Decrypts a secret box message ciphertext.
- encrypt()
- Encrypts a secret box message.
- makeKey()
- Makes a secret box key.
- makeNonce()
- Makes a secret box nonce with the correct length.
- validatedLengths()
- Validates key and nonce.
__construct()
public function __construct(string $key, string $nonce)
SecretBox constructor.
Parameters
- string $key
- string $nonce
decrypt()
public function decrypt(string $ciphertext): string|false
Decrypts a secret box message ciphertext.
Parameters
- string $ciphertext
Returns
string|false
encrypt()
public function encrypt(string $message): string
Encrypts a secret box message.
Parameters
- string $message
Returns
string
makeKey()
public static function makeKey(): string
Makes a secret box key.
Returns
string
makeNonce()
public static function makeNonce(): string
Makes a secret box nonce with the correct length.
Returns
string
validatedLengths()
protected function validatedLengths(string $key, string $nonce): void
Validates key and nonce.
Parameters
- string $key
- string $nonce
Returns
void