PHP 8.1.0 Released!

sodium_crypto_sign_verify_detached

(PHP 7 >= 7.2.0, PHP 8)

sodium_crypto_sign_verify_detachedVerify signature for the message

Description

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

Verify signature for the message

Liste de paramètres

signature

The cryptographic signature obtained from sodium_crypto_sign_detached()

message

The message being verified

public_key

Ed25519 public key

Valeurs de retour

Cette fonction retourne true en cas de succès ou false si une erreur survient.

add a note add a note

User Contributed Notes 1 note

up
1
Anonymous
1 year 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

?>
To Top