Aplus Framework Docs

SecretBox
in package

Class SecretBox.

Table of Contents

$key  : string
$nonce  : string
__construct()  : mixed
SecretBox constructor.
decrypt()  : false|string
Decrypts a secret box message ciphertext.
encrypt()  : string
Encrypts a secret box message.
makeKey()  : string
Makes a secret box key.
makeNonce()  : string
Makes a secret box nonce with the correct length.
validatedLengths()  : void
Validates key and nonce.

Properties

Methods

__construct()

SecretBox constructor.

public __construct(string $key, string $nonce) : mixed
Parameters
$key : string
$nonce : string
Tags
see
SecretBox::makeKey()
see
SecretBox::makeNonce()
throws
LengthException

if key or nonce has not the required length

Return values
mixed

decrypt()

Decrypts a secret box message ciphertext.

public decrypt(string $ciphertext) : false|string
Parameters
$ciphertext : string
Tags
throws
SodiumException
Return values
false|string

encrypt()

Encrypts a secret box message.

public encrypt(string $message) : string
Parameters
$message : string
Tags
throws
SodiumException
Return values
string

makeKey()

Makes a secret box key.

public static makeKey() : string
Return values
string

makeNonce()

Makes a secret box nonce with the correct length.

public static makeNonce() : string
Tags
throws
Exception

if fail to get random bytes

Return values
string

validatedLengths()

Validates key and nonce.

protected validatedLengths(string $key, string $nonce) : void
Parameters
$key : string
$nonce : string
Tags
throws
LengthException

if key or nonce has not the required length

Return values
void

Search results