-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathklopf.py
More file actions
25 lines (17 loc) · 696 Bytes
/
klopf.py
File metadata and controls
25 lines (17 loc) · 696 Bytes
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
# -*- coding: UTF-8 -*-
"""Klopf Codec - Polybius-based content encoding.
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)
"""
from ..__common__ import *
__examples__ = {
'enc(klopf|klopfcode)': {'this is a test': "44324234 4234 11 44513444"},
}
ENCMAP = {"ABCDEFGHIKLMNOPQRSTUVWXYZ"[y*5+x]: "".join([str(x+1), str(y+1)]) for x in range(5) for y in range(5)}
ENCMAP['J'] = "43"
ENCMAP[' '] = " "
add_map("klopf", ENCMAP, ignore_case="both", pattern=r"^(?:klopf(?:code)?)$", printables_rate=1.,
expansion_factor=(1.85, .15))