(s, p=0.01, n=None)
return s.tostring()
Corrupt a given percentage or number of bytes from a string
Corrupt a given percentage or number of bytes from a string
Corrupt a given percentage or number of bytes from a string
def corrupt_bytes(s, p=0.01, n=None):
    """Corrupt a given percentage or number of bytes from a string"""
    s = array.array("B",str(s))
    l = len(s)
    if n is None:
        n = max(1,int(l*p))
    for i in random.sample(xrange(l), n):
        s[i] = (s[i]+random.randint(1,255))%256
    return s.tostring()
def corrupt_bytes ( s , p = 0.01 , n = None ) : s = array . array ( "B" , str ( s ) ) l = len ( s ) if n is None : n = max ( 1 , int ( l * p ) ) for i in random . sample ( xrange ( l ) , n ) : s [ i ] = ( s [ i ] + random . randint ( 1 , 255 ) ) % 256 return s . tostring ( )