! Copyright (C) 2006, 2008 Doug Coleman. ! See http://factorcode.org/license.txt for BSD license. USING: byte-arrays grouping io.binary kernel make math ; IN: checksums.common : calculate-pad-length ( length -- length' ) [ 56 < 55 119 ? ] keep - ; : pad-last-block ( bytes big-endian? length -- blocks ) [ [ % ] 2dip 0x80 , [ 0x3f bitand calculate-pad-length % ] [ 3 shift 8 rot [ >be ] [ >le ] if % ] bi ] B{ } make 64 group ;