Skip to content

Kirby 6.0.0

$symmetricCrypto->decrypt()

Decrypts JSON data encrypted by SymmetricCrypto::encrypt() using the secret key or password

$symmetricCrypto->decrypt(string $json): string

Parameters

Name Type Default
$jsonrequired string no default value

Return type

string

Parent class

Kirby\Toolkit\SymmetricCrypto

Examples

// decryption with a password
$crypto     = new SymmetricCrypto(password: 'super secure');
$ciphertext = $crypto->encrypt('a very confidential string');
$plaintext  = $crypto->decrypt($ciphertext);
// $plaintext: 'a very confidential string'

// decryption with a previously generated key
$crypto    = new SymmetricCrypto(secretKey: $secretKey);
$plaintext = $crypto->decrypt('{"mode":"secretbox"...}');