Coverage for poff/base62.py : 92%
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
|
else: def ord_byte(byte): return byte
''' 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)
_encode_chunk(binstr, i) for i in range(0, nchunks) ])
''' gets a chunk from the input data, converts it to a number and encodes that number '''
''' encodes an integer of 8*chunklen[0] bits using the specified alphabet ''' ALPHABET[(val//len(ALPHABET)**i) % len(ALPHABET)] for i in reversed(range(chunklen[1])) ])
''' parses a chunk of bytes to integer using big-endian representation ''' 256**(chunklen[0]-1-i) * ord_byte(chunk[i]) for i in range(chunklen[0]) ])
''' partition the data into chunks and retrieve the chunk at the given index ''' |