Changeset 22846 for ext

Show
Ignore:
Timestamp:
11/01/08 16:01:10 (2 months ago)
Author:
masak
Message:

[ext/MD5-Digest] understood term "little-endian" and made appropriate changes

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • ext/MD5-Digest/md5.perl5

    r22845 r22846  
    1414 = (0x01234567, 0x89ABCDEF, 0xFEDCBA98, 0x76543210); 
    1515 
    16 my $original_string = ""; 
     16my $original_string = ''; 
    1717 
    1818my @bits = split '', unpack 'B*', $original_string; 
     
    2020push @bits, 1; 
    2121push @bits, 0 until @bits % 512 == 448; 
    22 push @bits, split "", sprintf "%064b", $unpadded_message_bit_length; 
     22push @bits, split "", 
     23            scalar reverse sprintf "%064b", 
     24            $unpadded_message_bit_length; 
    2325 
    2426my @chunks; 
     
    2931    my @chunk = @{$chunkref}; 
    3032    my @w; 
    31     push @w, oct(join '', '0b', splice(@chunk, 0, 32)) while @chunk; 
     33    push @w, oct(join '', '0b', reverse splice(@chunk, 0, 32)) 
     34        while @chunk; 
    3235 
    3336    my ($a, $b, $c, $d) = ($h0, $h1, $h2, $h3); 
     
    5558} 
    5659 
    57 my $digest = sprintf "%08x"x4, $h0, $h1, $h2, $h3; 
     60my $digest 
     61    = join '', map { scalar reverse sprintf "%08x", $_ } $h0, $h1, $h2, $h3; 
    5862print $digest, "\n"; 
    5963