php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #6361 unpack fails with 'H'
Submitted: 2000-08-25 19:04 UTC Modified: 2000-09-17 17:08 UTC
From: alex at iniciando dot com Assigned:
Status: Closed Package: *General Issues
PHP Version: 4.0.1pl2 OS: RH Linux 6.0
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: alex at iniciando dot com
New email:
PHP Version: OS:

 

 [2000-08-25 19:04 UTC] alex at iniciando dot com
This script fails complaining about there isn't enougth data for unpack:

$md5_val = '0123456789abcdef0123456789abcdef';
print "{$md5_val}<br>\n";
$binary_md5 = pack('H32', $md5_val);

$md5_val = unpack('H32a', $binary_md5);
$md5_val = $md5_val['a'];
print "{$md5_val}<br>\n";

It's corresponding perl scripts works fine:

#!/usr/bin/perl
$md5_val = '0123456789abcdef0123456789abcdef';
print "$md5_val\n";
$binary_md5 = pack('H32', $md5_val);

($md5_val) = unpack('H32', $binary_md5);
print "$md5_val\n";

Workarround:

$md5_val = unpack('H32a', $binary_md5.$binary_md5);

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2000-08-31 09:29 UTC] stas@php.net
Well, PHP unpack seems to behave differently from perl's unpack here. In Perl, number behind H is the number of nibbles, in PHP - number of characters (which is different for the unpack). I don't know if this is an intended behaviour...
 [2000-09-17 17:08 UTC] stas@php.net
Should be fixed in CVS, please check.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 16 13:01:32 2024 UTC