#! /usr/bin/env python t = "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ" assert len(t) <= 64 f = open('/dev/random','rb') s = '' while len(s) < 8: c = ord(f.read(1)) & 63 if c < len(t): s += t[c] print s