@Test public void testme(){ SimpleFuzz fuzz = new SimpleFuzz(123); String s1 = "1111111111_1111111111_1111111111_1111111111_1111111111_" + "1111111111_1111111111_1111111111_1111111111_1111111111_"; byte[] b1 = s1.getBytes(); byte[] b2 = fuzz.fuzz(b1, 20); Assert.assertEquals(b1, s1.getBytes()); Assert.assertNotEquals(b1, b2); }
public byte[] fuzz(byte[] src, int permillage){ if( null == src ){ throw new IllegalArgumentException("Src should NOT be null."); } if( permillage > 1000 || permillage < 0){ throw new IllegalArgumentException("Permillage must between 0 and 1000."); } int srclen = src.length; byte[] dst = ByteUtil.copyOf(src, srclen); int fuzzNum = srclen * permillage / 1000; for(int i=0; i<fuzzNum; i++){ int pos = RandomUtil.nextInt(srclen); dst[pos] = fuzz(dst[pos]); } return dst; }
SimpleFuzz { public byte[] fuzz(byte[] src, int permillage){ if( null == src ){ throw new IllegalArgumentException("Src should NOT be null."); } if( permillage > 1000 || permillage < 0){ throw new IllegalArgumentException("Permillage must between 0 and 1000."); } int srclen = src.length; byte[] dst = ByteUtil.copyOf(src, srclen); int fuzzNum = srclen * permillage / 1000; for(int i=0; i<fuzzNum; i++){ int pos = RandomUtil.nextInt(srclen); dst[pos] = fuzz(dst[pos]); } return dst; } }
SimpleFuzz { public byte[] fuzz(byte[] src, int permillage){ if( null == src ){ throw new IllegalArgumentException("Src should NOT be null."); } if( permillage > 1000 || permillage < 0){ throw new IllegalArgumentException("Permillage must between 0 and 1000."); } int srclen = src.length; byte[] dst = ByteUtil.copyOf(src, srclen); int fuzzNum = srclen * permillage / 1000; for(int i=0; i<fuzzNum; i++){ int pos = RandomUtil.nextInt(srclen); dst[pos] = fuzz(dst[pos]); } return dst; } SimpleFuzz(int seed); }
SimpleFuzz { public byte[] fuzz(byte[] src, int permillage){ if( null == src ){ throw new IllegalArgumentException("Src should NOT be null."); } if( permillage > 1000 || permillage < 0){ throw new IllegalArgumentException("Permillage must between 0 and 1000."); } int srclen = src.length; byte[] dst = ByteUtil.copyOf(src, srclen); int fuzzNum = srclen * permillage / 1000; for(int i=0; i<fuzzNum; i++){ int pos = RandomUtil.nextInt(srclen); dst[pos] = fuzz(dst[pos]); } return dst; } SimpleFuzz(int seed); byte[] fuzz(byte[] src, int permillage); byte fuzz(byte src); int fuzz(int src); long fuzz(long src); }
SimpleFuzz { public byte[] fuzz(byte[] src, int permillage){ if( null == src ){ throw new IllegalArgumentException("Src should NOT be null."); } if( permillage > 1000 || permillage < 0){ throw new IllegalArgumentException("Permillage must between 0 and 1000."); } int srclen = src.length; byte[] dst = ByteUtil.copyOf(src, srclen); int fuzzNum = srclen * permillage / 1000; for(int i=0; i<fuzzNum; i++){ int pos = RandomUtil.nextInt(srclen); dst[pos] = fuzz(dst[pos]); } return dst; } SimpleFuzz(int seed); byte[] fuzz(byte[] src, int permillage); byte fuzz(byte src); int fuzz(int src); long fuzz(long src);  }