note 120161 added to function.hash

From: Date: Mon, 14 Nov 2016 21:02:03 +0000
Subject: note 120161 added to function.hash
Groups: php.notes 
Request: Send a blank email to php-notes+get-207100@lists.php.net to get a copy of this message
If you want to calculate the sha-256 of an entire message with a secret key, make sure you have a look at hash_hmac(). The outputs of hash_hmac() and hash() will be different even if you try to add the secret at the start of the message wile passing it to hash(). eg: $hash1 = hash('sha256', 'my_secret_key_for_msg' . 'actual_message_body'); // 3ad6f68e51099abc212961110d01001fa9b995c9032df42acdbcd4d5e425066a $hash2 = hash_hmac('sha256', 'actual_message_body', 'my_secret_key_for_msg', false); // 416d24dd7be053a6bfb9aa25fac8070838bef19c75e75489dd82ffd190c27f0d /** * hash1 is not be equal to hash2 */ ---- Server IP: 72.52.91.14 Probable Submitter: 50.192.52.13 ---- Manual Page -- http://php.net/manual/en/function.hash.php Edit -- https://master.php.net/note/edit/120161 Del: integrated -- https://master.php.net/note/delete/120161/integrated Del: useless -- https://master.php.net/note/delete/120161/useless Del: bad code -- https://master.php.net/note/delete/120161/bad+code Del: spam -- https://master.php.net/note/delete/120161/spam Del: non-english -- https://master.php.net/note/delete/120161/non-english Del: in docs -- https://master.php.net/note/delete/120161/in+docs Del: other reasons-- https://master.php.net/note/delete/120161 Reject -- https://master.php.net/note/reject/120161 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#207100) next »