Paste: internet checksum (RFC 1071)
Author: | mrjbq7 |
Mode: | factor |
Date: | Thu, 5 Aug 2010 03:30:54 |
Plain Text |
USING: checksums io.binary kernel math sequences ;
IN: checksums.internet
SINGLETON: internet
INSTANCE: internet checksum
M: internet checksum-bytes
drop 0 swap [ dup empty? ] [
2 short cut-slice [ le> + ] dip
] until drop
[ -16 shift ] [ HEX: ffff bitand ] bi +
[ -16 shift ] keep + bitnot 2 >le ;
Author: | mrjbq7 |
Mode: | factor |
Date: | Thu, 5 Aug 2010 03:38:04 |
Plain Text |
M: internet checksum-bytes
drop 0 swap 2 <sliced-groups> [ le> + ] each
[ -16 shift ] [ HEX: ffff bitand ] bi +
[ -16 shift ] keep + bitnot 2 >le ;
New Annotation