Skip to content

Kirby 6.0.0

$symmetricCrypto->encrypt()

Encrypts a string using the secret key or password

$symmetricCrypto->encrypt(string $string): non-empty-string

Parameters

Name Type Default
$stringrequired string no default value

Return type

non-empty-string

Parent class

Kirby\Toolkit\SymmetricCrypto

Examples

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

// encryption with a random key
$crypto     = new SymmetricCrypto();
$ciphertext = $crypto->encrypt('a very confidential string');
$secretKey  = $crypto->secretKey();