3 base91_alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
4 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
5 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
6 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
7 '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '#', '$',
8 '%', '&', '(', ')', '*', '+', ',', '.', '/', ':', ';', '<', '=',
9 '>', '?', '@', '[', ']', '^', '_', '`', '{', '|', '}', '~', '"']
11 decode_table = dict((v,k) for k,v in enumerate(base91_alphabet))
13 def decode(encoded_str):
18 for strletter in encoded_str:
19 if not strletter in dectable:
21 c = dectable[strletter]
27 n += 13 if (v & 8191)>88 else 14
29 out += struct.pack('B', b&255)
36 out += struct.pack('B', (b | v << n) & 255 )