RIPEMD-160: Difference between revisions

→‎{{header|Raku}}: FP style (should also be faster)
(→‎{{header|Raku}}: FP style (should also be faster))
Line 1,290:
$b.push: |(8 * $data).polymod: 256 xx 7;
blob8.new: (
my blob32 $word .= new: $b.rotor(4).map: { :256[@^x.reverse] };
}reduce
my buf32 $h .= new: 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0;
-> blob32 $h, @words {
loop (my $i = 0; $i < @$word; $i += 16) {
my buf32blob32 ($X, $Y) = $h.clone xx 2;reduce
-> [$X, for ^80 ->$Y], $j {
$X[] = [blob32.new($X[4], rotl(($X[0] + @F[ $j div 16](|$X[1..3]) + ($word@words[$i+r1[$j]] // 0) + @K1[$j]) mod 2**32, s1[$j]) + $X[4], $X[1], rotl($X[2], 10), $X[3]];),
$Y[] = [blob32.new($Y[4], rotl(($Y[0] + @F[(79-$j) div 16](|$Y[1..3]) + ($word@words[$i+r2[$j]] // 0) + @K2[$j]) mod 2**32, s2[$j]) + $Y[4], $Y[1], rotl($Y[2], 10), $Y[3]]);
}, blob32.new($h).clone xx 2, |^80;
}
blob32.new: $h[] = [$h[1,2,3,4,0] Z+ $X[2,3,4,0,1] Z+ $Y[3,4,0,1,2]];
},
}
(BEGIN my buf32 $h blob32.= new: (0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0;)),
return blob8.new: $h.map: |*.polymod: 256 xx 3;
my |blob32 $word .= new: ($b.rotor(4).map: { :256[@^x.reverse] }).rotor(16);
return blob8.new: $h).map: |*.polymod: (256 xx 3);
}</syntaxhighlight>
 
1,934

edits