static byte[] pad(byte[] data){
  int len;
  if (data.length < 8)   len=data.length;
 else   len=data.length % 8;
  if (len == 0)   return data;
 else {
    byte[] padding=new byte[8 - len + data.length];
    for (int i=padding.length - 1; i > data.length - 1; i--) {
      padding[i]=0;
    }
    System.arraycopy(data,0,padding,0,data.length);
    return padding;
  }
}

static byte [ ] pad ( byte [ ] data ) { int len ; if ( data . length < 8 ) len = data . length ; else len = data . length % 8 ; if ( len == 0 ) return data ; else { byte [ ] padding = new byte [ 8 - len + data . length ] ; for ( int i = padding . length - 1 ; i > data . length - 1 ; i -- ) { padding [ i ] = 0 ; } System . arraycopy ( data , 0 , padding , 0 , data . length ) ; return padding ; } }
pads the data so that its length is a multiple of 8 bytes .
