private static boolean matches(byte[] bytes, int offset, byte[] key) {
    if (offset < 0 || offset + key.length > bytes.length) {
      throw new IllegalArgumentException();
    }
    for (int i = 0; i < key.length; i++) {
      if (bytes[i + offset] != key[i]) {
        return false;
      }
    }
    return true;
  }
private static boolean matches(byte[] bytes, int offset, byte[] key)