تابع ووکامرسی hash_equals تطابق رشته و هش شده آن

تابع ووکامرسی hash_equals – تطابق رشته و هش شده آن ( داده کد گذاری شده )
Syntax – سینتکس
hash_equals( (string) $a, (string) $b );
Parameters – پارامتر ها (2)
- 1- $a (string)
- 2- $b (string)
Usage – نحوه استفاده
if ( !function_exists( 'hash_equals' ) ) {
require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-core-functions.php';
}
// Expected string.
$a = '';
// Actual string.
$b = '';
// NOTICE! Understand what this does before running.
$result = hash_equals($a, $b);
Defined – محل تعریف
/includes/wc-core-functions.php
function hash_equals( $a, $b ) {
$a_length = strlen( $a );
if ( strlen( $b ) !== $a_length ) {
return false;
}
$result = 0;
// Do not attempt to "optimize" this.
for ( $i = 0; $i < $a_length; $i++ ) {
$result |= ord( $a[ $i ] ) ^ ord( $b[ $i ] );
}
return 0 === $result;
}
versions – نسخه ها
از نسخه : 3.9.2
نسخه فعلی : 3.0.6
دیگر نسخه ها : 3.0.6 , 3.0.5 , 3.0.4 , 3.0.3 , 3.0.2
ارسال نظر