eggcrypt 1.4.0__tar.gz → 2.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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eggcrypt
3
- Version: 1.4.0
3
+ Version: 2.0.0
4
4
  Summary: A pretty secure (yet inneficient) encryption program. Has key(), hash(), encrypt() and decrypt().
5
5
  Author: Egglord
6
6
  License: MIT
@@ -18,13 +18,13 @@ This is my fifth python library :D
18
18
 
19
19
  Commands:
20
20
 
21
- eggcrypt.encrypt("") # Returns an encrypted string.
21
+ eggcrypt.encrypt("text", "key") # Returns an encrypted string.
22
22
 
23
- eggcrypt.decrypt("") # Returns a non-encrypted string.
23
+ eggcrypt.decrypt("ciphertext", "key") # Returns a non-encrypted string.
24
24
 
25
25
  eggcrypt.key() # Returns a random key/seed.
26
26
 
27
- eggcrypt.hash("") # Uses a custom method to hash a string.
27
+ eggcrypt.hash("") # Uses a custom method to hash a string. Input: str or int.
28
28
 
29
29
  # !NB!
30
30
 
@@ -6,13 +6,13 @@ This is my fifth python library :D
6
6
 
7
7
  Commands:
8
8
 
9
- eggcrypt.encrypt("") # Returns an encrypted string.
9
+ eggcrypt.encrypt("text", "key") # Returns an encrypted string.
10
10
 
11
- eggcrypt.decrypt("") # Returns a non-encrypted string.
11
+ eggcrypt.decrypt("ciphertext", "key") # Returns a non-encrypted string.
12
12
 
13
13
  eggcrypt.key() # Returns a random key/seed.
14
14
 
15
- eggcrypt.hash("") # Uses a custom method to hash a string.
15
+ eggcrypt.hash("") # Uses a custom method to hash a string. Input: str or int.
16
16
 
17
17
  # !NB!
18
18
 
@@ -1,50 +1,53 @@
1
- def encrypt(txt,rep=0):
2
- a=[]
3
- b=""
4
- c=""
5
- for i in txt:
6
- b=ord(i)
7
- for j in str(b):
8
- c+=str(int(j)+200)
9
- if len(c)> 4:
10
- a.append(chr(int(c)))
11
- c=""
12
- txt=""
13
- for i in a:
14
- txt+=i
15
- if rep==1:
16
- return txt
17
- else:
18
- return encrypt(txt,1)
19
- def decrypt(txt, rep=0):
1
+ def encrypt(txt, key, rep=0):
2
+ encoded=""
3
+ for i, ch in enumerate(txt):
4
+ b=ord(ch)^ord(key[i%len(key)])
5
+ for digit in str(b):
6
+ encoded+=f"{int(digit)+200:03d}"
7
+ out=""
8
+ for i in range(0, len(encoded),2):
9
+ chunk=encoded[i:i+2]
10
+ if len(chunk)==2:
11
+ out+=chr(int(chunk))
12
+ else:
13
+ out+=chr(int(chunk)*10)
14
+ if rep:
15
+ return out
16
+ return encrypt(out,key,1)
17
+ def decrypt(txt, key, rep=0):
20
18
  if rep==0:
21
- txt=decrypt(txt, 1)
22
- digits=""
19
+ txt=decrypt(txt,key,1)
20
+ encoded=""
23
21
  for ch in txt:
24
- num=ord(ch)
25
- digits+=str(num)
26
- result=""
27
- for i in range(0, len(digits), 3):
28
- chunk=digits[i:i+3]
29
- if len(chunk) ==3:
30
- original_digit=int(chunk)-200
31
- result += str(original_digit)
32
- final=""
22
+ n=ord(ch)
23
+ if n<100:
24
+ encoded+=f"{n//10}"
25
+ else:
26
+ encoded+=f"{n:02d}"
27
+ digits=""
28
+ for i in range(0,len(encoded),3):
29
+ part=encoded[i:i+3]
30
+ if len(part)==3:
31
+ digits+=str(int(part)-200)
32
+ values=[]
33
33
  temp=""
34
- for d in result:
34
+ for d in digits:
35
35
  temp+=d
36
36
  if int(temp)>31:
37
- final+=chr(int(temp))
37
+ values.append(int(temp))
38
38
  temp=""
39
- return final
39
+ result=""
40
+ for i, v in enumerate(values):
41
+ result+=chr(v^ord(key[i%len(key)]))
42
+ return result
40
43
  def key():
41
44
  import time
42
45
  seed=1
43
46
  for i in range(int(time.time()*10000)%100):
44
- a=str(time.time()*10000)
45
- a=a[0:10]
46
- a=int(a)
47
- seed=int(seed*a+(round(seed^a)))
47
+ a=str(time.time()*10000)
48
+ a=a[0:10]
49
+ a=int(a)
50
+ seed=int(seed*a+(round(seed^a)))
48
51
  return seed
49
52
  def hash(inp):
50
53
  inp=str(inp)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: eggcrypt
3
- Version: 1.4.0
3
+ Version: 2.0.0
4
4
  Summary: A pretty secure (yet inneficient) encryption program. Has key(), hash(), encrypt() and decrypt().
5
5
  Author: Egglord
6
6
  License: MIT
@@ -18,13 +18,13 @@ This is my fifth python library :D
18
18
 
19
19
  Commands:
20
20
 
21
- eggcrypt.encrypt("") # Returns an encrypted string.
21
+ eggcrypt.encrypt("text", "key") # Returns an encrypted string.
22
22
 
23
- eggcrypt.decrypt("") # Returns a non-encrypted string.
23
+ eggcrypt.decrypt("ciphertext", "key") # Returns a non-encrypted string.
24
24
 
25
25
  eggcrypt.key() # Returns a random key/seed.
26
26
 
27
- eggcrypt.hash("") # Uses a custom method to hash a string.
27
+ eggcrypt.hash("") # Uses a custom method to hash a string. Input: str or int.
28
28
 
29
29
  # !NB!
30
30
 
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "eggcrypt"
7
- version = "1.4.0"
7
+ version = "2.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"
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="egg",
5
- version="1.4.0",
5
+ version="2.0.0",
6
6
  packages=find_packages(),
7
7
  description="A pretty secure (yet inneficient) encryption program.",
8
8
  author="Egglord",
File without changes
File without changes
File without changes