Anonymous user
CRC-32: Difference between revisions
m
→{{header|REXX}}: simplified the code, used a template for the output section.
m (→{{header|REXX}}: simplified the code, used a template for the output section.) |
|||
Line 1,877:
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
CRC_32: procedure; parse arg !,$;
/* [↓] handle each rightmost byte bit.*/
$=bitxor( word($ '0000000'x, 1), f) /*utilize the user's CRC or a default. */
?= bitxor(right($,1), substr(!,k,1) )
end
return $ /*return with cyclic redundancy check. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
show: procedure; parse arg Xstring; numeric digits 12; say; say
checksum= bitxor(CRC_32(Xstring),
say center(' input string [length of' length(Xstring) "bytes] ", 79, '═')
say Xstring;
▲ "dec CRC-32 checksum =" c2d(checksum) /*show the CRC-32 in hex and dec.*/
return</lang>
{{out|output|text= when using the internal default input:}}
<pre>
══════════════════════ input string [length of 43 bytes] ══════════════════════
|