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 : pad-last-block ( str big-endian? length -- str )
15 [ HEX: 3f bitand calculate-pad-length <byte-array> % ]
16 [ 3 shift 8 rot [ >be ] [ >le ] if % ] bi
17 ] B{ } make 64 group ;
19 : update-old-new ( old new -- )
20 [ [ get ] bi@ w+ dup ] 2keep [ set ] bi@ ; inline