(PHP 7 >= 7.2.0, PHP 8)
sodium_memzero — Écrase une chaîne avec des caractères NUL
sodium_memzero() remplace par des zéros la chaîne passée par référence.
stringChaîne.
Aucune valeur n'est retournée.
<?php
$key = random_bytes(SODIUM_CRYPTO_SECRETBOX_KEYBYTES);
$message = "Customer financial data";
$nonce = random_bytes(SODIUM_CRYPTO_SECRETBOX_NONCEBYTES);
$ciphertext = sodium_crypto_secretbox($message, $nonce, $key);
// Key no longer needed
sodium_memzero($key);
var_dump($key); // Usually becomes an empty string