Documentation

unsign

string public
\Bitrix\Main\Security\Sign\Signer::unsign(
 string $signedValue,
 string|null $salt = null
);

Non-static method verifies signature and returns original message.

Parameter

ParameterDescriptionVersion
$signedValueSigned value, must have the format: "{message}{separator}{signature}".
$saltSalt, if required.

Exceptions

Example

 $signer = new Signer;

 // Sing message
 $signedValue = $signer->sign('test');

 // Get original message with checking
 echo $signer->unsign($signedValue);
 // Output: 'test'

 // Try to unsigning not signed value
 echo $signer->unsign('test');
 //throw BadSignatureException with message 'Separator not found in value'

 // Or with invalid sign
 echo $signer->unsign('test.invalid_sign');

 // Or invalid salt
 //throw BadSignatureException with message 'Signature does not match'
 echo $signer->unsign($signedValue, 'invalid_salt');



© «Bitrix24», 2001-2024