略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: sodium_crypto_sign_verify_detached

2024-11-14

sodium_crypto_sign_verify_detached

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_sign_verify_detachedVerify signature for the message

说明

sodium_crypto_sign_verify_detached(string $signature, string $message, string $public_key): bool

Verify signature for the message

参数

signature

The cryptographic signature obtained from sodium_crypto_sign_detached()

message

The message being verified

public_key

Ed25519 public key

返回值

成功时返回 true, 或者在失败时返回 false

add a noteadd a note

User Contributed Notes 1 note

up
1
Anonymous
2 years ago
<?php

$message
= 'The quick brown fox jumped over the lazy dog.';

# Generate keypair
$keyPair = sodium_crypto_sign_keypair();

# Sign a message
$secKey = sodium_crypto_sign_secretkey($keyPair);
$signature = sodium_crypto_sign_detached($message, $secKey);

# Verify a message
$pubKey = sodium_crypto_sign_publickey($keyPair);
$verifyResult = sodium_crypto_sign_verify_detached($signature, $message, $pubKey);

var_dump($verifyResult); # true or false

?>

官方地址:https://www.php.net/manual/en/function.sodium-crypto-sign-verify-detached.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3