class CryptoPublic

libsodium wrapper class for public-key authenticated crypto

Methods

static array
GenerateKeyPair()

Generates a public/private keypair

static string
Encrypt(string $message, string $nonce, string $recipient_public, string $sender_private)

Encrypts and signs data from a sender to a recipient

static string
Decrypt(string $message, string $nonce, string $recipient_private, string $sender_public)

Decrypts and verifies data from a sender to a recipient

Details

at line 103
static array GenerateKeyPair()

Generates a public/private keypair

Return Value

array

{public:string, private:string}

at line 120
static string Encrypt(string $message, string $nonce, string $recipient_public, string $sender_private)

Encrypts and signs data from a sender to a recipient

Parameters

string $message

the plaintext to encrypt

string $nonce

the nonce to encrypt with

string $recipient_public

the recipient's public key

string $sender_private

the sender's private key

Return Value

string

the encrypted and signed ciphertext

at line 137
static string Decrypt(string $message, string $nonce, string $recipient_private, string $sender_public)

Decrypts and verifies data from a sender to a recipient

Parameters

string $message

the ciphertext to decrypt

string $nonce

the nonce that was used to encrypt

string $recipient_private

the recipient's private key

string $sender_public

the sender's public key

Return Value

string

the decrypted and verified plaintext

Exceptions

DecryptionFailedException

if decryption fails