Ejemplo n.º 1
0
 private void readInternal(ByteBuffer dst, long position, int len) throws IOException {
   int x = dst.position();
   readFully(base, position + HEADER_LENGTH, dst);
   long block = position / BLOCK_SIZE;
   while (len > 0) {
     xts.decrypt(block++, BLOCK_SIZE, dst.array(), dst.arrayOffset() + x);
     x += BLOCK_SIZE;
     len -= BLOCK_SIZE;
   }
 }
Ejemplo n.º 2
0
 private void writeInternal(ByteBuffer src, long position, int len) throws IOException {
   ByteBuffer crypt = ByteBuffer.allocate(len);
   crypt.put(src);
   crypt.flip();
   long block = position / BLOCK_SIZE;
   int x = 0, l = len;
   while (l > 0) {
     xts.encrypt(block++, BLOCK_SIZE, crypt.array(), crypt.arrayOffset() + x);
     x += BLOCK_SIZE;
     l -= BLOCK_SIZE;
   }
   writeFully(base, position + HEADER_LENGTH, crypt);
 }