]> gitweb.factorcode.org Git - factor.git/blob - basis/checksums/common/common.factor
Fixing basis -> extra dependencies
[factor.git] / basis / checksums / common / common.factor
1 ! Copyright (C) 2006, 2008 Doug Coleman.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: kernel math math.bitwise strings io.binary namespaces
4 grouping ;
5 IN: checksums.common
6
7 SYMBOL: bytes-read
8
9 : calculate-pad-length ( length -- pad-length )
10     dup 56 < 55 119 ? swap - ;
11
12 : pad-last-block ( str big-endian? length -- str )
13     [
14         rot %
15         HEX: 80 ,
16         dup HEX: 3f bitand calculate-pad-length 0 <string> %
17         3 shift 8 rot [ >be ] [ >le ] if %
18     ] "" make 64 group ;
19
20 : update-old-new ( old new -- )
21     [ get >r get r> ] 2keep >r >r w+ dup r> set r> set ; inline