X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=base91.py;h=f407d44c44db856250c53cd5489837ea84e1a602;hb=3f8b562ea10431add0ce06079f303f130d0280be;hp=e970a09b2f14d44c4f76adb802eea6c728aa3455;hpb=078973b9cf248d4276c044528fbd9b1682fa89d8;p=secnet.git diff --git a/base91.py b/base91.py deleted file mode 100644 index e970a09..0000000 --- a/base91.py +++ /dev/null @@ -1,38 +0,0 @@ -import struct - -base91_alphabet = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', - 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', - 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', - 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', - '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '!', '#', '$', - '%', '&', '(', ')', '*', '+', ',', '.', '/', ':', ';', '<', '=', - '>', '?', '@', '[', ']', '^', '_', '`', '{', '|', '}', '~', '"'] - -decode_table = dict((v,k) for k,v in enumerate(base91_alphabet)) - -def decode(encoded_str): - v = -1 - b = 0 - n = 0 - out = bytearray() - for strletter in encoded_str: - if not strletter in dectable: - continue - c = dectable[strletter] - if(v < 0): - v = c - else: - v += c*91 - b |= v << n - n += 13 if (v & 8191)>88 else 14 - while True: - out += struct.pack('B', b&255) - b >>= 8 - n -= 8 - if not n>7: - break - v = -1 - if v+1: - out += struct.pack('B', (b | v << n) & 255 ) - return out - diff --git a/base91.py b/base91.py new file mode 120000 index 0000000..f407d44 --- /dev/null +++ b/base91.py @@ -0,0 +1 @@ +base91-python/base91/__init__.py \ No newline at end of file