|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2021-09-24 10:15 UTC] cmb@php.net
-Status: Open
+Status: Not a bug
-Assigned To:
+Assigned To: cmb
[2021-09-24 10:15 UTC] cmb@php.net
[2021-09-24 19:14 UTC] php at wfuchs dot de
[2021-09-24 19:54 UTC] salathe@php.net
[2021-09-25 12:25 UTC] php at wfuchs dot de
[2021-09-25 15:43 UTC] requinix@php.net
[2021-09-25 15:58 UTC] requinix@php.net
-Status: Not a bug
+Status: Re-Opened
-Type: Bug
+Type: Documentation Problem
-Assigned To: cmb
+Assigned To:
[2021-09-25 15:58 UTC] requinix@php.net
[2021-09-27 12:34 UTC] git@php.net
[2021-09-27 12:34 UTC] git@php.net
-Status: Re-Opened
+Status: Closed
[2021-09-27 15:24 UTC] git@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 15:00:01 2025 UTC |
Description: ------------ Tested Versions: PHP 8.0.11 (cli) (built: Sep 23 2021 21:26:24) PHP 7.4.24 (cli) (built: Sep 23 2021 21:36:11) Compiled by Ondřej Surý for Ubuntu 20.04 In the PHP function "hash_pbkdf2" the key is truncated in hex (default). With a length of 64 bytes it should be 128 hexits and not 64 hexits. If the key is generated binary and converted to hex the length is correct with 128 hexits. Test script: --------------- <?php $algo = "sha256"; $password = "S€cur@Päßw#rd"; $salt = random_bytes(16); $iterations = 10000; $binhash = hash_pbkdf2($algo, $password, $salt, $iterations, 64, TRUE); echo ("Converted to HEX:" . PHP_EOL); var_dump(bin2hex($binhash)); $hexhash = hash_pbkdf2($algo, $password, $salt, $iterations, 64); echo ("HEX generated:" . PHP_EOL); var_dump($hexhash); ?> Expected result: ---------------- Converted to HEX: string(128) "b94864e32adfd58bd9324ed058ed3c40e0134f98af8abde2535576bab28ddd3e3c205381c33a705f63d75db4c340ccec288985f9ff1b917c53b419ee166083d0" HEX generated: string(128) "b94864e32adfd58bd9324ed058ed3c40e0134f98af8abde2535576bab28ddd3e3c205381c33a705f63d75db4c340ccec288985f9ff1b917c53b419ee166083d0" Actual result: -------------- Converted to HEX: string(128) "b94864e32adfd58bd9324ed058ed3c40e0134f98af8abde2535576bab28ddd3e3c205381c33a705f63d75db4c340ccec288985f9ff1b917c53b419ee166083d0" HEX generated: string(64) "b94864e32adfd58bd9324ed058ed3c40e0134f98af8abde2535576bab28ddd3e"