sodium_memzero

(PHP 7 >= 7.2.0, PHP 8)

sodium_memzero文字列をNUL文字で上書きする

説明

function sodium_memzero(#[\SensitiveParameter] string &$string): void

sodium_memzero() は、 リファレンス渡しされた文字列をゼロ埋めします。

パラメータ

string
文字列

戻り値

値を返しません。

add a note

User Contributed Notes 1 note

up
1
Anonymous
7 days ago
<?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