]> gitweb.factorcode.org Git - factor.git/blob - basis/checksums/common/common.factor
checksums.common: some cleanup, remove unused stuff.
[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: byte-arrays grouping io.binary kernel make math ;
4 IN: checksums.common
5
6 : calculate-pad-length ( length -- length' )
7     [ 56 < 55 119 ? ] keep - ;
8
9 : pad-last-block ( bytes big-endian? length -- blocks )
10     [
11         [ % ] 2dip 0x80 ,
12         [ 0x3f bitand calculate-pad-length <byte-array> % ]
13         [ 3 shift 8 rot [ >be ] [ >le ] if % ] bi
14     ] B{ } make 64 group ;