<?php
$message = 'The quick brown fox jumped over the lazy dog.';
# 生成密钥对
$keyPair = sodium_crypto_sign_keypair();
# 签名消息
$secKey = sodium_crypto_sign_secretkey($keyPair);
$signature = sodium_crypto_sign_detached($message, $secKey);
# 验证消息
$pubKey = sodium_crypto_sign_publickey($keyPair);
$verifyResult = sodium_crypto_sign_verify_detached($signature, $message, $pubKey);
var_dump($verifyResult); # true 或 false
?>