哈希空间 Ctrl + F 进行搜索
首页 php手册中文版 CSS中文手册 哈希文档 Markdown在线工具

PHP sodium 组件

sodium_memcmp

(PHP 7 >= 7.2.0, PHP 8)

sodium_memcmpTest for equality in constant-time

说明

sodium_memcmp(string $string1, string $string2): int

Compare two strings in constant-time.

In practice, you almost always want to use hash_equals() instead, since it provides the same logic but returns a bool instead of an int. However, if you're using the return value of a comparison in a calculation that's timing-sensitive, and worried about timing leaks with bool-to-int conversions, sodium_memcmp() is an ideal replacement.

参数

string1

String to compare

string2

Other string to compare

返回值

Returns 0 if both strings are equal; -1 otherwise.

打开 哈希空间 微信小程序中查看更佳