public boolean decrypt(ByteBuffer buf){
  final byte[] data=buf.array();
  final int size=buf.remaining();
  byte[] clientPacketKey=keys[CLIENT];
  int arrayIndex=buf.arrayOffset() + buf.position();
  int prev=data[arrayIndex];
  data[arrayIndex++]^=(clientPacketKey[0] & 0xff);
  for (int i=1; i < size; i++, arrayIndex++) {
    int curr=data[arrayIndex] & 0xff;
    data[arrayIndex]^=(staticKey[i & 63] & 0xff) ^ (clientPacketKey[i & 7] & 0xff) ^ prev;
    prev=curr;
  }
  long oldKey=(((long)clientPacketKey[0] & 0xff) << 0) | (((long)clientPacketKey[1] & 0xff) << 8) | (((long)clientPacketKey[2] & 0xff) << 16)| (((long)clientPacketKey[3] & 0xff) << 24)| (((long)clientPacketKey[4] & 0xff) << 32)| (((long)clientPacketKey[5] & 0xff) << 40)| (((long)clientPacketKey[6] & 0xff) << 48)| (((long)clientPacketKey[7] & 0xff) << 56);
  oldKey+=size;
  if (validateClientPacket(buf)) {
    clientPacketKey[0]=(byte)(oldKey >> 0 & 0xff);
    clientPacketKey[1]=(byte)(oldKey >> 8 & 0xff);
    clientPacketKey[2]=(byte)(oldKey >> 16 & 0xff);
    clientPacketKey[3]=(byte)(oldKey >> 24 & 0xff);
    clientPacketKey[4]=(byte)(oldKey >> 32 & 0xff);
    clientPacketKey[5]=(byte)(oldKey >> 40 & 0xff);
    clientPacketKey[6]=(byte)(oldKey >> 48 & 0xff);
    clientPacketKey[7]=(byte)(oldKey >> 56 & 0xff);
    return true;
  }
  return false;
}

public boolean decrypt ( ByteBuffer buf ) { final byte [ ] data = buf . array ( ) ; final int size = buf . remaining ( ) ; byte [ ] clientPacketKey = keys [ CLIENT ] ; int arrayIndex = buf . arrayOffset ( ) + buf . position ( ) ; int prev = data [ arrayIndex ] ; data [ arrayIndex ++ ] ^= ( clientPacketKey [ 0 ] & 0xff ) ; for ( int i = 1 ; i < size ; i ++ , arrayIndex ++ ) { int curr = data [ arrayIndex ] & 0xff ; data [ arrayIndex ] ^= ( staticKey [ i & 63 ] & 0xff ) ^ ( clientPacketKey [ i & 7 ] & 0xff ) ^ prev ; prev = curr ; } long oldKey = ( ( ( long ) clientPacketKey [ 0 ] & 0xff ) << 0 ) | ( ( ( long ) clientPacketKey [ 1 ] & 0xff ) << 8 ) | ( ( ( long ) clientPacketKey [ 2 ] & 0xff ) << 16 ) | ( ( ( long ) clientPacketKey [ 3 ] & 0xff ) << 24 ) | ( ( ( long ) clientPacketKey [ 4 ] & 0xff ) << 32 ) | ( ( ( long ) clientPacketKey [ 5 ] & 0xff ) << 40 ) | ( ( ( long ) clientPacketKey [ 6 ] & 0xff ) << 48 ) | ( ( ( long ) clientPacketKey [ 7 ] & 0xff ) << 56 ) ; oldKey += size ; if ( validateClientPacket ( buf ) ) { clientPacketKey [ 0 ] = ( byte ) ( oldKey > > 0 & 0xff ) ; clientPacketKey [ 1 ] = ( byte ) ( oldKey > > 8 & 0xff ) ; clientPacketKey [ 2 ] = ( byte ) ( oldKey > > 16 & 0xff ) ; clientPacketKey [ 3 ] = ( byte ) ( oldKey > > 24 & 0xff ) ; clientPacketKey [ 4 ] = ( byte ) ( oldKey > > 32 & 0xff ) ; clientPacketKey [ 5 ] = ( byte ) ( oldKey > > 40 & 0xff ) ; clientPacketKey [ 6 ] = ( byte ) ( oldKey > > 48 & 0xff ) ; clientPacketKey [ 7 ] = ( byte ) ( oldKey > > 56 & 0xff ) ; return true ; } return false ; }
decrypt client packet from this bytebuffer if decryption is successful , update client key
