Overview
KB
Technical FAQ
PHP Manual
CSS2 Manual
HTML Manual
JS Guide
JS Reference
PhpDock Manual
Nu-Coder Manual
PhpExpress Manual
PHP Joomla
Development
Learn PHP
 
<sodium_bin2hexsodium_crypto_aead_aegis128l_decrypt>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026

sodium_compare

(PHP 7 >= 7.2.0, PHP 8)

sodium_compare — Compare large numbers

Description

function sodium_compare(#[\SensitiveParameter] string $string1, #[\SensitiveParameter] string $string2): int

Compare two strings as if they were arbitrary-length, unsigned little-endian integers, without side-channel leakage.

Parameters

string1

Left operand

string2

Right operand

Return Values

Returns -1 if string1 is less than string2.

Returns 1 if string1 is greater than string2.

Returns 0 if both strings are equal.


<sodium_bin2hexsodium_crypto_aead_aegis128l_decrypt>
^Sodium FunctionsLast updated: Mon, 26 Oct 2026