eggcrypt 2.1.0__tar.gz → 3.0.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.
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/PKG-INFO +1 -1
- eggcrypt-3.0.0/eggcrypt/egg.py +183 -0
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/eggcrypt.egg-info/PKG-INFO +1 -1
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/pyproject.toml +1 -1
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/setup.py +1 -1
- eggcrypt-2.1.0/eggcrypt/egg.py +0 -58
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/LICENSE +0 -0
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/README.md +0 -0
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/eggcrypt/__init__.py +0 -0
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/eggcrypt.egg-info/SOURCES.txt +0 -0
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/eggcrypt.egg-info/dependency_links.txt +0 -0
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/eggcrypt.egg-info/top_level.txt +0 -0
- {eggcrypt-2.1.0 → eggcrypt-3.0.0}/setup.cfg +0 -0
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
def hash2(inp):
|
|
2
|
+
inp=str(inp)
|
|
3
|
+
H=[0x243f6a8885a308d3,0x13198a2e03707344,0xa4093822299f31d0,0x082efa98ec4e6c89]
|
|
4
|
+
for i,c in enumerate(inp):
|
|
5
|
+
x=ord(c)+(i<<8)
|
|
6
|
+
j=i%4
|
|
7
|
+
H[j]^=x
|
|
8
|
+
H[j]=(H[j]*0x100000001b3)&0xffffffffffffffff
|
|
9
|
+
H[(j+1)%4]^=H[j]>>17
|
|
10
|
+
key_str=''.join(f'{x:016x}' for x in H)
|
|
11
|
+
tot=sum((i+1)*ord(c) for i,c in enumerate(key_str))
|
|
12
|
+
for i in inp:
|
|
13
|
+
tot^=ord(i)
|
|
14
|
+
out=""
|
|
15
|
+
for i in key_str:
|
|
16
|
+
v=int(i,16)
|
|
17
|
+
out+=str(v+((tot*v)%256))
|
|
18
|
+
o=""
|
|
19
|
+
for i in out:o+=chr((int(i)+tot)%256)
|
|
20
|
+
out=""
|
|
21
|
+
for i in range(len(o)-1):out+=str(i*tot+ord(o[i]))
|
|
22
|
+
for n in map(int,[out[i:i+2] for i in range(0,len(out),2)]):o+=chr(n+32)
|
|
23
|
+
if len(out)%2:o+=chr(int(out[-1])*21)
|
|
24
|
+
o=o.lstrip("0123456789")
|
|
25
|
+
h=0
|
|
26
|
+
for c in o:
|
|
27
|
+
h^=ord(c)
|
|
28
|
+
h=((h<<13)|(h >> 243))&((1<<256)-1)
|
|
29
|
+
h=(h*0x9e3779b97f4a7c15)&((1<<256)-1)
|
|
30
|
+
chars="0123456789abcdefghijklmnopqrstuvwxyz"
|
|
31
|
+
x=""
|
|
32
|
+
while h:x=chars[h%36]+x;h//=36
|
|
33
|
+
out=x.zfill(50)
|
|
34
|
+
return out
|
|
35
|
+
def makesbox(key):
|
|
36
|
+
prev=hash2(key)
|
|
37
|
+
stream=[]
|
|
38
|
+
while len(stream)<256:
|
|
39
|
+
n=int(prev,36)
|
|
40
|
+
for _ in range(50):
|
|
41
|
+
stream.append(n&255)
|
|
42
|
+
n>>=8
|
|
43
|
+
if len(stream)>=256:
|
|
44
|
+
break
|
|
45
|
+
prev=hash2(prev)
|
|
46
|
+
unused=list(range(256))
|
|
47
|
+
sbox=[]
|
|
48
|
+
for i in range(255,-1,-1):
|
|
49
|
+
b=stream.pop()% (i+1)
|
|
50
|
+
sbox.append(unused.pop(b))
|
|
51
|
+
return sbox
|
|
52
|
+
def xor_text(txt,key):
|
|
53
|
+
key=str(key)
|
|
54
|
+
out=""
|
|
55
|
+
for i,ch in enumerate(txt):
|
|
56
|
+
out+=chr(ord(ch)^ord(key[i%len(key)]))
|
|
57
|
+
return out
|
|
58
|
+
def diffuse(data):
|
|
59
|
+
data=[ord(c) for c in data]
|
|
60
|
+
for i in range(1,len(data)):
|
|
61
|
+
data[i]^=data[i-1]
|
|
62
|
+
return "".join(chr(x) for x in data)
|
|
63
|
+
def undiffuse(data):
|
|
64
|
+
data=[ord(c) for c in data]
|
|
65
|
+
for i in range(len(data)-1,0,-1):
|
|
66
|
+
data[i]^=data[i-1]
|
|
67
|
+
return "".join(chr(x) for x in data)
|
|
68
|
+
def rol(x):
|
|
69
|
+
return ((x<<1)|(x>>7))&0xff
|
|
70
|
+
def diffuse2(data):
|
|
71
|
+
data=[ord(c) for c in data]
|
|
72
|
+
for i in range(1,len(data)):
|
|
73
|
+
data[i]^=rol(data[i-1])
|
|
74
|
+
return "".join(chr(x) for x in data)
|
|
75
|
+
def undiffuse2(data):
|
|
76
|
+
data=[ord(c) for c in data]
|
|
77
|
+
for i in range(len(data)-1,0,-1):
|
|
78
|
+
data[i]^=rol(data[i-1])
|
|
79
|
+
return "".join(chr(x) for x in data)
|
|
80
|
+
def round_sbox(key,r):
|
|
81
|
+
round_key=xor_text(str(key),hash2(str(key)+str(r*0x9E3779B97F4A7C15)))
|
|
82
|
+
return makesbox(round_key)
|
|
83
|
+
def roundkey(key,r):
|
|
84
|
+
return int(hash2(str(key)+str(r*0x9E3779B97F4A7C15)),36)
|
|
85
|
+
def permute(data, perm):
|
|
86
|
+
return "".join(data[i] for i in perm)
|
|
87
|
+
def make_perm(n, key=7):
|
|
88
|
+
perm=[]
|
|
89
|
+
used=set()
|
|
90
|
+
x=key&0x7fffffff
|
|
91
|
+
for _ in range(n):
|
|
92
|
+
x=(x*1103515245+12345)&0x7fffffff
|
|
93
|
+
pos=x%n
|
|
94
|
+
while pos in used:
|
|
95
|
+
pos=(pos+1)%n
|
|
96
|
+
used.add(pos)
|
|
97
|
+
perm.append(pos)
|
|
98
|
+
return perm
|
|
99
|
+
def inverse_perm(perm):
|
|
100
|
+
inv=[0]*len(perm)
|
|
101
|
+
for new_pos, old_pos in enumerate(perm):
|
|
102
|
+
inv[old_pos]=new_pos
|
|
103
|
+
return inv
|
|
104
|
+
def encrypt(txt,key):
|
|
105
|
+
for r in range(10):
|
|
106
|
+
txt=xor_text(txt,roundkey(key,r))
|
|
107
|
+
sbox=round_sbox(key,r)
|
|
108
|
+
out=""
|
|
109
|
+
for ch in txt:
|
|
110
|
+
out+=chr(sbox[ord(ch)])
|
|
111
|
+
txt=diffuse2(out)
|
|
112
|
+
txt=diffuse(txt)
|
|
113
|
+
perm=make_perm(len(txt), roundkey(key,r))
|
|
114
|
+
txt=permute(txt,perm)
|
|
115
|
+
for r in range(22):
|
|
116
|
+
txt=xor_text(txt, hash2(hash2(r)+hash2(key)))
|
|
117
|
+
txt=diffuse2(txt)
|
|
118
|
+
final_perm =make_perm(len(txt), roundkey(key,999))
|
|
119
|
+
txt=permute(txt,final_perm)
|
|
120
|
+
return txt
|
|
121
|
+
def decrypt(txt,key):
|
|
122
|
+
final_perm=make_perm(len(txt),roundkey(key,999))
|
|
123
|
+
txt=permute(txt,inverse_perm(final_perm))
|
|
124
|
+
txt=undiffuse2(txt)
|
|
125
|
+
for r in range(21,-1,-1):
|
|
126
|
+
txt=xor_text(txt,hash2(hash2(r)+hash2(key)))
|
|
127
|
+
for r in range(9,-1,-1):
|
|
128
|
+
perm=make_perm(len(txt),roundkey(key,r))
|
|
129
|
+
txt=permute(txt, inverse_perm(perm))
|
|
130
|
+
txt=undiffuse(txt)
|
|
131
|
+
txt=undiffuse2(txt)
|
|
132
|
+
sbox=round_sbox(key,r)
|
|
133
|
+
inv=[0]*256
|
|
134
|
+
for i,v in enumerate(sbox):
|
|
135
|
+
inv[v]=i
|
|
136
|
+
out=""
|
|
137
|
+
for ch in txt:
|
|
138
|
+
out+=chr(inv[ord(ch)])
|
|
139
|
+
txt=xor_text(out,roundkey(key,r))
|
|
140
|
+
return txt
|
|
141
|
+
def key():
|
|
142
|
+
import time
|
|
143
|
+
seed=1
|
|
144
|
+
for i in range(int(time.time()*10000)%100):
|
|
145
|
+
a=str(time.time()*10000)
|
|
146
|
+
a=a[0:10]
|
|
147
|
+
a=int(a)
|
|
148
|
+
seed=int(seed*a+(round(seed^a)))
|
|
149
|
+
return seed
|
|
150
|
+
def hash(inp):
|
|
151
|
+
inp=str(inp)
|
|
152
|
+
H=[0x243f6a8885a308d3,0x13198a2e03707344,0xa4093822299f31d0,0x082efa98ec4e6c89]
|
|
153
|
+
for i,c in enumerate(inp):
|
|
154
|
+
x=ord(c)+(i<<8)
|
|
155
|
+
j=i%4
|
|
156
|
+
H[j]^=x
|
|
157
|
+
H[j]=(H[j]*0x100000001b3)&0xffffffffffffffff
|
|
158
|
+
H[(j+1)%4]^=H[j]>>17
|
|
159
|
+
key_str=''.join(f'{x:016x}' for x in H)
|
|
160
|
+
tot=sum((i+1)*ord(c) for i,c in enumerate(key_str))
|
|
161
|
+
for i in inp:
|
|
162
|
+
tot^=ord(i)
|
|
163
|
+
out=""
|
|
164
|
+
for i in key_str:
|
|
165
|
+
v=int(i,16)
|
|
166
|
+
out+=str(v+((tot*v)%256))
|
|
167
|
+
o=""
|
|
168
|
+
for i in out:o+=chr((int(i)+tot)%256)
|
|
169
|
+
out=""
|
|
170
|
+
for i in range(len(o)-1):out+=str(i*tot+ord(o[i]))
|
|
171
|
+
for n in map(int,[out[i:i+2] for i in range(0,len(out),2)]):o+=chr(n+32)
|
|
172
|
+
if len(out)%2:o+=chr(int(out[-1])*21)
|
|
173
|
+
o=o.lstrip("0123456789")
|
|
174
|
+
h=0
|
|
175
|
+
for c in o:
|
|
176
|
+
h^=ord(c)
|
|
177
|
+
h=((h<<13)|(h >> 243))&((1<<256)-1)
|
|
178
|
+
h=(h*0x9e3779b97f4a7c15)&((1<<256)-1)
|
|
179
|
+
chars="0123456789abcdefghijklmnopqrstuvwxyz"
|
|
180
|
+
x=""
|
|
181
|
+
while h:x=chars[h%36]+x;h//=36
|
|
182
|
+
out=x.zfill(50)
|
|
183
|
+
return out
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "eggcrypt"
|
|
7
|
-
version = "
|
|
7
|
+
version = "3.0.0"
|
|
8
8
|
description = "A pretty secure (yet inneficient) encryption program. Has key(), hash(), encrypt() and decrypt()."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.8"
|
eggcrypt-2.1.0/eggcrypt/egg.py
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
def encrypt(txt,key):
|
|
2
|
-
data=""
|
|
3
|
-
for i,ch in enumerate(txt):
|
|
4
|
-
value=ord(ch)^ord(key[i%len(key)])
|
|
5
|
-
data+=f"{value:03d}"
|
|
6
|
-
return "".join(chr(int(data[i:i+3])) for i in range(0,len(data),3))
|
|
7
|
-
def decrypt(txt,key):
|
|
8
|
-
data=""
|
|
9
|
-
for ch in txt:
|
|
10
|
-
data+=f"{ord(ch):03d}"
|
|
11
|
-
result=""
|
|
12
|
-
nums=[int(data[i:i+3]) for i in range(0,len(data),3)]
|
|
13
|
-
for i,value in enumerate(nums):
|
|
14
|
-
result+=chr(value^ord(key[i%len(key)]))
|
|
15
|
-
return result
|
|
16
|
-
def key():
|
|
17
|
-
import time
|
|
18
|
-
seed=1
|
|
19
|
-
for i in range(int(time.time()*10000)%100):
|
|
20
|
-
a=str(time.time()*10000)
|
|
21
|
-
a=a[0:10]
|
|
22
|
-
a=int(a)
|
|
23
|
-
seed=int(seed*a+(round(seed^a)))
|
|
24
|
-
return seed
|
|
25
|
-
def hash(inp):
|
|
26
|
-
inp=str(inp)
|
|
27
|
-
H=[0x243f6a8885a308d3,0x13198a2e03707344,0xa4093822299f31d0,0x082efa98ec4e6c89]
|
|
28
|
-
for i,c in enumerate(inp):
|
|
29
|
-
x=ord(c)+(i<<8)
|
|
30
|
-
j=i%4
|
|
31
|
-
H[j]^=x
|
|
32
|
-
H[j]=(H[j]*0x100000001b3)&0xffffffffffffffff
|
|
33
|
-
H[(j+1)%4]^=H[j]>>17
|
|
34
|
-
key_str=''.join(f'{x:016x}' for x in H)
|
|
35
|
-
tot=sum((i+1)*ord(c) for i,c in enumerate(key_str))
|
|
36
|
-
for i in inp:
|
|
37
|
-
tot^=ord(i)
|
|
38
|
-
out=""
|
|
39
|
-
for i in key_str:
|
|
40
|
-
v=int(i,16)
|
|
41
|
-
out+=str(v+((tot*v)%256))
|
|
42
|
-
o=""
|
|
43
|
-
for i in out:o+=chr((int(i)+tot)%256)
|
|
44
|
-
out=""
|
|
45
|
-
for i in range(len(o)-1):out+=str(i*tot+ord(o[i]))
|
|
46
|
-
for n in map(int,[out[i:i+2] for i in range(0,len(out),2)]):o+=chr(n+32)
|
|
47
|
-
if len(out)%2:o+=chr(int(out[-1])*21)
|
|
48
|
-
o=o.lstrip("0123456789")
|
|
49
|
-
h=0
|
|
50
|
-
for c in o:
|
|
51
|
-
h^=ord(c)
|
|
52
|
-
h=((h<<13)|(h >> 243))&((1<<256)-1)
|
|
53
|
-
h=(h*0x9e3779b97f4a7c15)&((1<<256)-1)
|
|
54
|
-
chars="0123456789abcdefghijklmnopqrstuvwxyz"
|
|
55
|
-
x=""
|
|
56
|
-
while h:x=chars[h%36]+x;h//=36
|
|
57
|
-
out=x.zfill(50)
|
|
58
|
-
return out
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|