Box
in package
Uses
BoxTrait
Class Box.
Table of Contents
- $nonce : string|null
- $publicKey : string
- $secretKey : string
- __construct() : mixed
- Box constructor.
- decrypt() : false|string
- Decrypts a box message ciphertext.
- encrypt() : string
- Encrypts a box message.
- makeKeyPair() : string
- Makes a keypair.
- makeNonce() : string
- Makes a box nonce with the correct length.
- makePublicKey() : string
- Makes the public key from a keypair.
- makeSecretKey() : string
- Makes the secret key from a keypair.
- getKeyPair() : string
- Gets the keypair from the secret and public keys.
- getNonce() : string
- validateNonce() : void
- Validates a nonce.
Properties
$nonce
protected
string|null
$nonce
$publicKey
protected
string
$publicKey
$secretKey
protected
string
$secretKey
Methods
__construct()
Box constructor.
public
__construct(string $secretKey, string $publicKey[, string|null $nonce = null ]) : mixed
Parameters
- $secretKey : string
- $publicKey : string
- $nonce : string|null = null
Tags
Return values
mixed —decrypt()
Decrypts a box message ciphertext.
public
decrypt(string $ciphertext[, string|null $nonce = null ]) : false|string
Parameters
- $ciphertext : string
- $nonce : string|null = null
-
The message nonce or null to use the nonce set int the constructor
Tags
Return values
false|string —encrypt()
Encrypts a box message.
public
encrypt(string $message[, string|null $nonce = null ]) : string
Parameters
- $message : string
- $nonce : string|null = null
-
The message nonce or null to use the nonce set int the constructor
Tags
Return values
string —makeKeyPair()
Makes a keypair.
public
static makeKeyPair() : string
Tags
Return values
string —makeNonce()
Makes a box nonce with the correct length.
public
static makeNonce() : string
Tags
Return values
string —makePublicKey()
Makes the public key from a keypair.
public
static makePublicKey(string $keyPair) : string
Parameters
- $keyPair : string
Tags
Return values
string —makeSecretKey()
Makes the secret key from a keypair.
public
static makeSecretKey(string $keyPair) : string
Parameters
- $keyPair : string
Tags
Return values
string —getKeyPair()
Gets the keypair from the secret and public keys.
protected
getKeyPair() : string
Tags
Return values
string —getNonce()
protected
getNonce(string|null $nonce) : string
Parameters
- $nonce : string|null
Tags
Return values
string —validateNonce()
Validates a nonce.
protected
validateNonce(string $nonce) : void
Parameters
- $nonce : string