php - Comparing String Value -


i trying build hash of sha256 string using hash_hmac

$key = chr(hexdec('17')); // value of key blank  $test = chr(hexdec('17')) == '' ? true : false // value of test false 

so want know value of $key how can compare

$signature1 = hash_hmac('sha256', "st=1453362060~exp=1453363260~acl=/*", chr(hexdec('17'))); $signature2 = hash_hmac('sha256', "st=1453362060~exp=1453363260~acl=/*", "");  // signature1 == 020cb911b6415b14f6b1f955adf55be3b17bcbd77a3987408cb41406e39bfc82 // signature2 == 9356975e2119102a773dbd45e4f06d124246794a451c4aee320888bd3f857377 

why generating different key ?

the value of $key not directly printable has length different empty string not supplying same parameters hash_hmac function on both occasions. perhaps $test variable needs used?

if( !defined( 'br' ) ) define('br','<br />' );  $key = chr(hexdec('17')); $test = chr(hexdec('17')) == '' ? true : false;    $signature1 = hash_hmac('sha256', "st=1453362060~exp=1453363260~acl=/*", $test ); $signature2 = hash_hmac('sha256', "st=1453362060~exp=1453363260~acl=/*", '' );  echo 'key:'.$key.' length:'.strlen($key).' length:'.strlen('').br; echo $signature1.br.$signature2; 

output

key: length:1 length:0 728079ac9885314df2cc1207e8eb79ada329d7d4172ce6574a561c540f039c02 728079ac9885314df2cc1207e8eb79ada329d7d4172ce6574a561c540f039c02 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -