factor/basis/checksums/common/common.factor

22 lines
602 B
Factor
Raw Normal View History

2008-09-05 20:29:14 -04:00
! Copyright (C) 2006, 2008 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: kernel math math.bitwise strings io.binary namespaces
2008-09-10 23:11:40 -04:00
make grouping ;
2008-09-05 20:29:14 -04:00
IN: checksums.common
SYMBOL: bytes-read
: calculate-pad-length ( length -- pad-length )
dup 56 < 55 119 ? swap - ;
: pad-last-block ( str big-endian? length -- str )
[
rot %
HEX: 80 ,
dup HEX: 3f bitand calculate-pad-length 0 <string> %
3 shift 8 rot [ >be ] [ >le ] if %
] "" make 64 group ;
: update-old-new ( old new -- )
2008-11-26 05:25:18 -05:00
[ [ get ] bi@ w+ dup ] 2keep [ set ] bi@ ; inline