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 make grouping byte-arrays ;
9 : calculate-pad-length ( length -- length' )
10 [ 56 < 55 119 ? ] keep - ;
12 : calculate-pad-length-long ( length -- length' )
13 [ 120 < 119 247 ? ] keep - ;
15 : pad-last-block ( str big-endian? length -- str )
18 [ HEX: 3f bitand calculate-pad-length <byte-array> % ]
19 [ 3 shift 8 rot [ >be ] [ >le ] if % ] bi
20 ] B{ } make 64 group ;
22 : update-old-new ( old new -- )
23 [ [ get ] bi@ w+ dup ] 2keep [ set ] bi@ ; inline