XorCode 0.1.0__py3-none-any.whl

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.
XorCode/XorCode.py ADDED
@@ -0,0 +1,51 @@
1
+ import msgpack
2
+ import secrets
3
+ import numpy as np
4
+ import zlib
5
+
6
+ class XorCODE:
7
+ def ToNP(Input):
8
+ raw = msgpack.packb(Input)
9
+ NP = np.frombuffer(raw, dtype=np.uint8).copy()
10
+ return NP
11
+ def GenerateKeyFromSeed(seed:int,Length:int):
12
+ rng = np.random.default_rng(seed)
13
+ return rng.integers(0, 256, size=Length, dtype=np.uint8)
14
+ def GenerateKeyAsNarray(Length:int):
15
+ random_bytes=secrets.token_bytes(len(Length))
16
+ Key = np.frombuffer(random_bytes, dtype=np.uint8).copy()
17
+ return Key
18
+ def EncodeWithSeed(seed:int,Input):
19
+ Einput = Input.copy()
20
+ Key=XorCODE.GenerateKeyFromSeed(seed,len(Einput))
21
+ output=Einput^Key
22
+ return output.copy()
23
+ def DecodeWithSeed(seed:int,Input):
24
+ Einput = Input.copy()
25
+ Key=XorCODE.GenerateKeyFromSeed(seed,len(Einput))
26
+ output=Einput^Key
27
+ return msgpack.unpackb(output.tobytes())
28
+ def EncodeWithNarray(Input):
29
+ Einput=Input.copy()
30
+ Key=XorCODE.GenerateKeyAsNarray(Einput)
31
+ output=Einput^Key
32
+ return output.copy(),Key
33
+ def DecodeWithNarray(Input,Key):
34
+ Einput=Input.copy()
35
+ output=Einput^Key
36
+ return msgpack.unpackb(output.tobytes())
37
+ def ToNPZlib(Input):
38
+ raw = msgpack.packb(Input)
39
+ compressed_raw = zlib.compress(raw, level=6)
40
+ return np.frombuffer(compressed_raw, dtype=np.uint8).copy()
41
+ def DecodeWithSeedZlib(seed:int,Input):
42
+ Einput=Input.copy()
43
+ Key=XorCODE.GenerateKeyFromSeed(seed,len(Einput))
44
+ output = Einput^Key
45
+ Eoutput = zlib.decompress(output)
46
+ return msgpack.unpackb(Eoutput)
47
+ def DecodeWithNarrayZlib(Input,key):
48
+ Einput=Input.copy()
49
+ output=Einput^key
50
+ Eoutput = zlib.decompress(output)
51
+ return msgpack.unpackb(Eoutput)
XorCode/__init__.py ADDED
@@ -0,0 +1 @@
1
+ from XorCode import XorCODE
@@ -0,0 +1,9 @@
1
+ Metadata-Version: 2.4
2
+ Name: XorCode
3
+ Version: 0.1.0
4
+ Summary: a encryption and decryption that use XOR operation
5
+ Author-email: sloan rizzlerr <sloanngutierrez@gmail.com>
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: numpy
9
+ Requires-Dist: msgpack
@@ -0,0 +1,6 @@
1
+ XorCode/XorCode.py,sha256=ziTMnXMTEOsxE7L4eb6BLtIazZUFD7rTkiNqJYyaJ7A,1884
2
+ XorCode/__init__.py,sha256=e6xVXoRJRRXL5JXiqHFmc0CmYmgm0aMJUhkZsjnWpZ0,27
3
+ xorcode-0.1.0.dist-info/METADATA,sha256=8GKLSMEsS5U9X1bTjaVk4Z4oIfH_INx93sTTw7cKfYY,284
4
+ xorcode-0.1.0.dist-info/WHEEL,sha256=K260EYznzXsJYBQGqmI8VTxEdiZYNvDZwW9cBh9-_MA,91
5
+ xorcode-0.1.0.dist-info/top_level.txt,sha256=kTcS0KQJmB7naLcosAP3UP1gdtUarNWWoCGf8DEWMGA,8
6
+ xorcode-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (83.0.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1 @@
1
+ XorCode