forked from dhondta/python-codext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase85.py
More file actions
executable file
·50 lines (33 loc) · 1.44 KB
/
Copy pathbase85.py
File metadata and controls
executable file
·50 lines (33 loc) · 1.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# -*- coding: UTF-8 -*-
"""Base85 Codec - base85 content encoding.
This is a simple wrapper for adding base64.b85**code to the codecs.
This codec:
- en/decodes strings from str to str
- en/decodes strings from bytes to bytes
- decodes file content to str (read)
- encodes file content from str to bytes (write)
"""
import base64
from ._base import main
from ..__common__ import *
__examples__ = {'enc(base85|base-85|base_85)': {'this is a test': "bZBXFAZc?TVIXv6b94"}} if PY3 else \
{'enc(base85': None}
#FIXME: implement Z85 (ZeroMQ) in base85.py ; cfr spec https://rfc.zeromq.org/spec/32/
#FIXME: implement base85-rfc1924 in base85.py
#B85 = {
# r'': "!\"#$%&'()*+,-./" + digits + ":;<=>?@" + upper + "[\\]^_`" + lower[:21],
# r'[-_]z(eromq)?$': digits + upper + lower + ".-:+=^!/*?&<>()[]{}@%$#",
# r'[-_]rfc1924$': digits + upper + lower + "!#$%&()*+-;<=>?@^_`{|}~",
#}
#base(B85, r"^base[-_]?85(|[-_](?:z(?:eromq)?|rfc1924))$")
def base85_encode(input, errors='strict'):
raise NotImplementedError
def base85_decode(input, errors='strict'):
raise NotImplementedError
if PY3:
def base85_encode(input, errors='strict'):
return base64.b85encode(b(input)), len(input)
def base85_decode(input, errors='strict'):
return base64.b85decode(b(input)), len(input)
add("base85", base85_encode, base85_decode, r"^base[-_]?85$", entropy=7.05, expansion_factor=1.25)
main = main(85, "RFC 1924")