sodium_crypto_generichash_update

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_generichash_update — 해시에 메시지 추가


설명

sodium_crypto_generichash_update(string &$state, string $message): bool

내부 해시 상태에 메시지를 추가합니다.


매개변수

state
sodium_crypto_generichash_init()의 반환 값.
message
해싱 상태에 추가할 데이터입니다.

반환 값

성공하면 true를, 실패하면 false를 반환합니다.


Examples

예제 #1 sodium_crypto_generichash_update() 예제

                  
<?php
$messages = [random_bytes(32), random_bytes(32), random_bytes(16)];
$state = sodium_crypto_generichash_init();
foreach ($messages as $message) {
    sodium_crypto_generichash_update($state, $message);
}
$final = sodium_crypto_generichash_final($state);
var_dump(sodium_bin2hex($final));

$allAtOnce = sodium_crypto_generichash(implode('', $messages));
var_dump(sodium_bin2hex($allAtOnce));
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

string(64) "e16e28bbbbcc39d9f5b1cbc33c41f1d217808640103e57a41f24870f79831e04"
string(64) "e16e28bbbbcc39d9f5b1cbc33c41f1d217808640103e57a41f24870f79831e04"