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 ;
6 : calculate-pad-length ( length -- length' )
7 [ 56 < 55 119 ? ] keep - ;
9 : pad-last-block ( bytes big-endian? length -- blocks )
12 [ 0x3f bitand calculate-pad-length <byte-array> % ]
13 [ 3 shift 8 rot [ >be ] [ >le ] if % ] bi
14 ] B{ } make 64 group ;