EDcoder 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,53 @@
1
+ import math
2
+ table=["히히", "히힣", "힣히", "힣힣", "히ㅣ","ㅣ히","ㅣㅣ","히힛"]
3
+ def encode(S):
4
+ N = len(table)
5
+ bits = math.ceil(math.log2(N))
6
+
7
+ buff = ""
8
+ output = []
9
+
10
+ for c in S:
11
+ temp = bin(ord(c))[2:]
12
+ temp = "0" * (21 - len(temp)) + temp
13
+ buff += temp
14
+
15
+ while len(buff) >= bits:
16
+ idx = int(buff[:bits], 2)
17
+ if idx >= N:
18
+ # index가 table 범위를 넘으면 버리고 다음 비트로 진행
19
+ buff = buff[1:]
20
+ continue
21
+ output.append(table[idx])
22
+ buff = buff[bits:]
23
+
24
+ # 남은 비트 처리
25
+ if len(buff):
26
+ buff += "0" * (bits - len(buff))
27
+ idx = int(buff, 2)
28
+ if idx < N:
29
+ output.append(table[idx])
30
+
31
+ return ''.join(output)
32
+
33
+
34
+ def decode(S):
35
+ N = len(table)
36
+ bits = math.ceil(math.log2(N))
37
+ length = len(table[0])
38
+
39
+ B = ""
40
+
41
+ for i in range(0, len(S), length):
42
+ idx = table.index(S[i:i+length])
43
+ temp = bin(idx)[2:]
44
+ temp = "0" * (bits - len(temp)) + temp
45
+ B += temp
46
+
47
+ p = 0
48
+ output = ''
49
+ while p + 21 <= len(B):
50
+ output += chr(int(B[p:p+21], 2))
51
+ p += 21
52
+
53
+ return output
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: EDcoder
3
+ Version: 0.1.0
4
+ Summary: text encoder/decoder using custom table
5
+ Author-email: gimminjun <gimminjun163@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown
9
+
10
+ ...
11
+ This is a simple, custom en/decoder
@@ -0,0 +1,8 @@
1
+ README.md
2
+ pyproject.toml
3
+ EDcoder/__init__.py
4
+ EDcoder/edcoder.py
5
+ EDcoder.egg-info/PKG-INFO
6
+ EDcoder.egg-info/SOURCES.txt
7
+ EDcoder.egg-info/dependency_links.txt
8
+ EDcoder.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ EDcoder
edcoder-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,11 @@
1
+ Metadata-Version: 2.4
2
+ Name: EDcoder
3
+ Version: 0.1.0
4
+ Summary: text encoder/decoder using custom table
5
+ Author-email: gimminjun <gimminjun163@gmail.com>
6
+ License: MIT
7
+ Requires-Python: >=3.7
8
+ Description-Content-Type: text/markdown
9
+
10
+ ...
11
+ This is a simple, custom en/decoder
@@ -0,0 +1,2 @@
1
+ ...
2
+ This is a simple, custom en/decoder
@@ -0,0 +1,10 @@
1
+ [project]
2
+ name = "EDcoder"
3
+ version = "0.1.0"
4
+ description = "text encoder/decoder using custom table"
5
+ authors = [
6
+ { name="gimminjun", email="gimminjun163@gmail.com" }
7
+ ]
8
+ readme = "README.md"
9
+ license = { text = "MIT" }
10
+ requires-python = ">=3.7"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+