RIPEMD-160: Difference between revisions

→‎{{header|Raku}}: use concurrency
(→‎{{header|Raku}}: FP style (should also be faster))
(→‎{{header|Raku}}: use concurrency)
Line 1,292:
blob8.new: (
reduce
-> blob32 $h, @words {
blob32.new: $h[1,2,3,4,0]
my blob32 ($X, $Y) = reduce
Z+ start { reduce -> $X, $j { blob32.new($YX[4], rotl(($YX[0] + @F[(79- $j) div 16](|$YX[1..3]) + @words[r2r1[$j]] + @K2K1[$j]) mod 2**32, s2s1[$j]) + $YX[4], $YX[1], rotl($YX[2], 10), $YX[3]); }, $h.clone, |^80; }.result[2,3,4,0,1]
-> [$X, $Y], $j {
Z+ start { reduce -> $Y, $j { blob32.new($XY[4], rotl(($XY[0] + @F[ (79-$j ) div 16](|$XY[1..3]) + @words[r1r2[$j]] + @K1K2[$j]) mod 2**32, s1s2[$j]) + $XY[4], $XY[1], rotl($XY[2], 10), $XY[3]); }, $h.clone, |^80; }.result[3,4,0,1,2];
},
blob32.new($Y[4], rotl(($Y[0] + @F[(79-$j) div 16](|$Y[1..3]) + @words[r2[$j]] + @K2[$j]) mod 2**32, s2[$j]) + $Y[4], $Y[1], rotl($Y[2], 10), $Y[3]);
}, (BEGIN blob32.new($h).clone0x67452301, xx0xefcdab89, 20x98badcfe, |^80;0x10325476, 0xc3d2e1f0)),
|blob32.new: ($h[1,2,3,b.rotor(4,0]).map: Z+{ $X:256[2,3,4,0,1@^x.reverse] Z+ $Y[3,4,0,1,2]}).rotor(16);
},
(BEGIN blob32.new(0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0)),
|blob32.new($b.rotor(4).map: { :256[@^x.reverse] }).rotor(16);
).map: |*.polymod(256 xx 3);
}</syntaxhighlight>
1,934

edits