diff --git a/tunmgr/base.py b/tunmgr/base.py
new file mode 100644
index 0000000000000000000000000000000000000000..20f709d09ee39f7a76be471c65aa04f8969dd7d9
--- /dev/null
+++ b/tunmgr/base.py
@@ -0,0 +1,29 @@
+def basetoN(num,base):
+    current=num
+    while current!=0:
+        current, remainder=divmod(current, base)
+        yield remainder
+
+def basefromN(repr, base):
+    n = 0
+    puissance = 1
+    for chiffre in repr:
+        n+=chiffre*puissance
+        puissance*=base
+    return n
+
+def from7bytes(B):
+    n = 0
+    for i, b in enumerate(B):
+        n|=b<<(8*i)
+    return n
+
+def to7bytes(n):
+    for i in range(7):
+        yield (n&(0xff<<(8*i)))>>(8*i)
+
+if __name__=="__main__":
+    print(list(basetoN(12, 2)))
+    print(basefromN(basetoN(12, 2), 2))
+    print(from7bytes(b"abcdefg"))
+    print(bytes(to7bytes(from7bytes(b"abcdefg"))))