import os, signal, sys, time from random import randrange from twisted.internet import reactor, defer from twisted.python import failure from allmydata.util import fileutil, log from allmydata.util.encodingutil import unicode_platform, get_filesystem_encoding def insecurerandstr(n): return ''.join(map(chr, map(randrange, [0]*n, [256]*n))) def flip_bit(good, which): # flip the low-order bit of good[which] if which == -1: pieces = good[:which], good[-1:], "" else: pieces = good[:which], good[which:which+1], good[which+1:] return pieces[0] + chr(ord(pieces[1]) ^ 0x01) + pieces[2] def flip_one_bit(s, offset=0, size=None): """ flip one random bit of the string s, in a byte greater than or equal to offset and less than offset+size. """ if size is None: size=len(s)-offset i = randrange(offset, offset+size) result = s[:i] + chr(ord(s[i])^(0x01<