Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# 'full' repeats digits twice, to increase the probablity of a digit appearing in a default 16 # character password, for sites that suck at estimating entropy and requires digits to be present 'full': string.ascii_letters + 2 * string.digits + '!#$%&()*+,-./:;=?@[]^_|~', 'alpha': string.ascii_letters, 'numeric': string.digits, 'alphanumeric': string.ascii_letters + string.digits, }
''' integer ceiling division '''
''' computes the ideal conversion ratio for the given alphabet. A ratio is considered ideal when the number of bits in one output encoding chunk that don't add up to one input encoding chunk is minimal. ''' (i, i*8 / math.log(alph_len, 2)) for i in range(1, 7) ], key=lambda k: k[1] % 1)
''' general-purpose encoder. Encodes arbitrary binary data with a given specific base ("alphabet"). '''
self._encode_chunk(binstr, i) for i in range(0, nchunks) ])[:total_len]
''' gets a chunk from the input data, converts it to a number and encodes that number '''
''' encodes an integer of 8*self.chunklen[0] bits using the specified alphabet ''' self.alphabet[(val//len(self.alphabet)**i) % len(self.alphabet)] for i in reversed(range(self.chunklen[1])) ])
''' parses a chunk of bytes to integer using big-endian representation ''' 256**(self.chunklen[0]-1-i) * ord_byte(chunk[i]) for i in range(self.chunklen[0]) ])
''' partition the data into chunks and retrieve the chunk at the given index '''
''' retrieves a named charset or treats the input as a custom alphabet and use that ''' _logger.warning('very small alphabet in use, possibly a failed lookup?') |