public static byte [ ] zero_pad ( byte [ ] original , int block_size ) { if ( ( original . length % block_size ) == 0 ) { return original ; } byte [ ] result = new byte [ round_up ( original . length , block_size ) ] ; memcpy ( result , 0 , original , 0 , original . length ) ; // Unnecessary - jvm sets bytes to 0. // memclr (result, original.length, result.length - original.length); return result ; }
Return a new array equal to original except zero - padded to an integral mulitple of blocks . If the original is already an integral multiple of blocks just return it .