import sys, os, random, time

print "Sleeping 10 seconds"
start = time.time()
while time.time() - start < 10:
    pass
print "Reading randomness"

if os.fork() > 0:
    fd = os.open("/dev/random", os.O_RDONLY)
    n = 0
    cum = 0
    while 1:
        k = os.read(fd, 1)
        cum += ord(k)
        print "%2.2x" % ord(k),
        sys.stdout.flush()
        if n % 10 == 0:
            print "%x" % cum
        n += 1
        if n > 4096:
            break
else:
    fp = file("rand")
    fp.seek(0, 2)
    size = fp.tell()
    while 1:
        pos = random.randint(0, size - 10)
        fp.seek(pos)
        fp.read(5)

