public static List<BytesMutation> generateMutations(byte[] bytes) {
    List<BytesMutation> res = new ArrayList<>();

    // Flip bits.
    for (int i = 0; i < bytes.length; i++) {
      for (int j = 0; j < 8; j++) {
        byte[] modifiedBytes = Arrays.copyOf(bytes, bytes.length);
        modifiedBytes[i] = (byte) (modifiedBytes[i] ^ (1 << j));
        res.add(new BytesMutation(modifiedBytes, String.format("Flip bit %d of data", i)));
      }
    }

    // Truncate bytes.
    for (int i = 0; i < bytes.length; i++) {
      byte[] modifiedBytes = Arrays.copyOf(bytes, i);
      res.add(new BytesMutation(modifiedBytes, String.format("Truncate upto %d bytes of data", i)));
    }

    // Append an extra byte.
    res.add(new BytesMutation(Arrays.copyOf(bytes, bytes.length + 1), "Append an extra zero byte"));
    return res;
  }
Generates mutations of {@code bytes}, e.g., flipping bits and truncating.

@return a list of pairs of mutated value and mutation description.
java_src/src/main/java/com/google/crypto/tink/testing/TestUtil.java