diff --git a/PCSS/__init__.py b/PCSS/__init__.py index 2701c8d..4a74e33 100644 --- a/PCSS/__init__.py +++ b/PCSS/__init__.py @@ -8,7 +8,7 @@ makeid = lambda: hashlib.sha256( str( - random.randint(-999999999999999999999, 999999999999999999999 + time.time()) + random.randint(-2**512, 2**512 + time.time()) ).encode()).hexdigest() + hashlib.sha512(str(uuid1()).encode()).hexdigest( ) + str(uuid4()) + str(uuid5(uuid4(), str(uuid1()))) diff --git a/PCSS/__pycache__/__init__.cpython-310.pyc b/PCSS/__pycache__/__init__.cpython-310.pyc index 7655dae..4bb7195 100644 Binary files a/PCSS/__pycache__/__init__.cpython-310.pyc and b/PCSS/__pycache__/__init__.cpython-310.pyc differ diff --git a/PCSS/__pycache__/hash.cpython-310.pyc b/PCSS/__pycache__/hash.cpython-310.pyc index f17b67f..0c7876b 100644 Binary files a/PCSS/__pycache__/hash.cpython-310.pyc and b/PCSS/__pycache__/hash.cpython-310.pyc differ diff --git a/PCSS/hash.py b/PCSS/hash.py index 443d695..ff2e3fb 100644 --- a/PCSS/hash.py +++ b/PCSS/hash.py @@ -1,17 +1,67 @@ from bitarray import bitarray +from bitarray.util import int2ba from hashlib import sha256 +from random import shuffle, seed -def hash(data: str, length: int = 256) -> str: +def pad_bitarray_left(ba, size=4): + # Calculate the number of bits to pad + pad_size = size - len(ba) + + # Create a new bitarray for padding + pad = bitarray(pad_size) + pad.setall(0) + + # Prepend the padding to the original bitarray + ba[:0] = pad + return ba + + +def merge_bitarrays(*bitarrays): + merged_bitarray = bitarray() + + # Extend the result bitarray with each bitarray in the list + for ba in bitarrays: + merged_bitarray.extend(ba) + return merged_bitarray + + +def split_bitarray(ba, block_size=4): + return [ + pad_bitarray_left(ba[i:i + block_size], block_size) + for i in range(0, len(ba), block_size) + ] + + +def hash(data: str, length: int = 256, block_size: int = 4) -> str: + """ + Hashes data using the hashing PCSS algorithm. + The length of the hash is supplied as the length arguemnt and it must be divisible by the block size (which defaults to 4). + An increased block size results in increased randomness. + """ + if length % block_size != 0: + raise ValueError("Length must be a multiple of block_size") encoded = bitarray() encoded.frombytes(data.encode('utf-8')) - blocks = [encoded[i:i + 4] for i in range(0, len(encoded), 4)] - fourbits = [bitarray(4) for _ in range(length)] - for index, i in enumerate(fourbits): + hash_data = [ + encoded, + int2ba(len(data)), + int2ba(length), + int2ba(encoded.count(1)) + ] + blocks = [] + for x in hash_data: + blocks = blocks + split_bitarray(x, block_size) + emptyblocks = [bitarray(block_size) for _ in range(length)] + seed((length + block_size + len(data)) * int(blocks[0].to01(), 2)) + for index, i in enumerate(emptyblocks): + i.setall(0) + shuffle(blocks) for block in blocks: i ^= block x = bitarray(blocks[min(index, len(blocks) - 1)]) x.reverse() i ^= ~x - fourbits[index] = ~i - return ''.join('{:x}'.format(int(i.to01(), 2)) for i in fourbits) + emptyblocks[index] = ~i + return ''.join('{:x}'.format(int(i.to01(), 2)) + for i in split_bitarray(merge_bitarrays(*emptyblocks), 4)) diff --git a/Projxon_Cyber_Security_System.egg-info/PKG-INFO b/Projxon_Cyber_Security_System.egg-info/PKG-INFO deleted file mode 100644 index c27f746..0000000 --- a/Projxon_Cyber_Security_System.egg-info/PKG-INFO +++ /dev/null @@ -1,74 +0,0 @@ -Metadata-Version: 2.1 -Name: Projxon-Cyber-Security-System -Version: 0.1.1 -Summary: A fast and unbreakable encrytion system. -Download-URL: https://github.com/hg0428/Projxon-Cyber-Security-System/archive/refs/tags/stable-0.1.1.tar.gz -Author: Hudson Gouge -Classifier: Intended Audience :: Developers -Classifier: Topic :: Software Development :: Build Tools -Classifier: Programming Language :: Python :: 3 -Classifier: License :: OSI Approved :: MIT License -Classifier: Operating System :: OS Independent -Requires-Python: >=3.7 -Description-Content-Type: text/markdown -License-File: LICENSE.txt - -# What is it? -A fast and unbreakable encrytion system. -This library has 3 functions, `makeid`, `encrypt`, and `decrypt`. - -`makeid` will generate a long, virtually collision-proof identifier. - -These tools can be very useful in login systems. - -# Installation -You can install it with pip. -`pip install Projxon-Cyber-Security-System` - - -# Usage - -## Encyrpt and Decrypt -```py -from PCSS import encrypt, decrypt - -# Encode it so that we have a bytes object to pass to encrypt -text = "Hello World!" -key = "key" - -# Encode it so that we have a bytes object to pass to encrypt - -encoded_text = text.encode() -encoded_key = key.encode() - - -# Encrypt the text -encrypted_bitarray = encrypt(encoded_text, encoded_key) -print(encrypted_bitarray) -# bitarray('00110110101010000111000011100000110100000110001010100110010000101000000000100000101000000010100010001100010011000010010001101100101011001010110011001100100111000010010010000110010011000110101010101100001001000100001011100010110011100111011000101110011000100101111001101010000111000001011010011110111000100001111001011110011011100110110011101010001101100010110001010110001100101111011010011100111100101010111010011100000100100101001001100010010010100111001001011110100111001001011011101100010010100110111001010010110011000100001010000110000100100101101000101100111101101100110000011100110000100100110011110010001011101110110011001100000110101000110001110110111000101111010011110110101011100100101010101100110101101101011000101010110010101011001001110100010001101000101010101100011011001011011001101110100100101010101011001110101011000011011011101100100001101111011001011110010010101010110011101110') - -# Decrypt the bitarray -decrypted_bitarray = decrypt(encrypted_bitarray, encoded_key) - -# Change it back into bytes -decrypted_bytes = decrypted_bitarray.tobytes() - -# Remove the trailing 0s and convert to string -decrypted_text = decrypted_bytes.rstrip(b'\x00').decode() - -print(decrypted_text, text == decrypted_text) -# Hello World! True -``` - - -## Generate id -```py -from PCSS import makeid - -print(makeid()) -# 3fbe99d84c1b9255565c79d758bebba6e011ba2ca0795c5c50d22519adaf99050e74cb261933091fc4c52d6a7581c3681557e4adf495b1cd1314579e962791efc6d5ceb9133de75cd25a20a99d50cf4b7bf927f61dfa298d69d573da101f26a973241224-a5eb-49fa-828b-f86b89d9a4745480679b-4d20-5b8a-a72b-268877dc086a -# ids will vary. -``` -These ids are garunteed to be unique, the chance of collision is about 1 / (2.42721841x10^229). -For refernce, the number of atoms in the universe is estimated to be 10^78. - diff --git a/Projxon_Cyber_Security_System.egg-info/SOURCES.txt b/Projxon_Cyber_Security_System.egg-info/SOURCES.txt deleted file mode 100644 index eacd289..0000000 --- a/Projxon_Cyber_Security_System.egg-info/SOURCES.txt +++ /dev/null @@ -1,12 +0,0 @@ -LICENSE.txt -README.md -pyproject.toml -setup.cfg -setup.py -/home/runner/Projxon-Cyber-Security-System/PCSS/__init__.py -/home/runner/Projxon-Cyber-Security-System/PCSS/hash.py -/home/runner/Projxon-Cyber-Security-System/Projxon_Cyber_Security_System.egg-info/PKG-INFO -/home/runner/Projxon-Cyber-Security-System/Projxon_Cyber_Security_System.egg-info/SOURCES.txt -/home/runner/Projxon-Cyber-Security-System/Projxon_Cyber_Security_System.egg-info/dependency_links.txt -/home/runner/Projxon-Cyber-Security-System/Projxon_Cyber_Security_System.egg-info/requires.txt -/home/runner/Projxon-Cyber-Security-System/Projxon_Cyber_Security_System.egg-info/top_level.txt \ No newline at end of file diff --git a/README.md b/README.md index be74c53..26cc24a 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,7 @@ from PCSS import encrypt, decrypt, makeid, bitarray_to_text from PCSS.hash import hash print(f""" +Hash of Hi!: {hash("Hi!")} Hash of Hello_World!: {hash("Hello_World!")} Hash of Hello_World! : {hash("Hello_World! ")} Hash of Hello World: {hash("Hello World")} @@ -29,36 +30,35 @@ Hash of !#!#!#!#!#!#!#!#: {hash("!#!#!#!#!#!#!#!#")} """) # Output: """ -Hash of Hello_World!: 133e15fbd573507fd63714d032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032fe1032547698badcfe1032 -Hash of Hello_World! : 6ac3ec8eac8ea90aafcaeda5832107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba9854ba98fedc32107654bfeecddc32107654ba98fedc3 -Hash of Hello World: 026b0426c4c941a2c762056789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123ef0123456789abcdef0455766789abcdef012345182439abcdef01234567 -Hash of Password#123: 7ad07a98bc5ffa9e967052b89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd2301cd23016745ab89efcd26775445ab89efcd2301673a061b89efcd230164f5bacd23016745ab89efb -Hash of AAAAAAAAAAAA: 4fa183e5c7290b6d4fa183e56789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab6789abcdef012345678cddfeef0123456789abcd90acb123456789abce5f106789abcdef0123d6e0f789abcdef01234567 -Hash of !#!#!#!#!#!#!#!#: 5a781e34d2f096bc5a781e34d2f096bcdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef23cdef89ab45670123c899baab45670123cdef89d4e8f5670123cdef8a1b5423cdef89ab456792a4b3cdef89ab456700d165ef89ab45670123cdef7067ccc +Hash of Hi!: 32aa253325323f2f7a22f52313272b77335b11b25327aab12772a3522522bf77322223233227222ff2ff3b33332a27252b3ff323127b2335ba752f2a1f3b22122b2b23522522af3f22f522a735f273112332f722b227f122b22111f22222532f75327172332271377a2ffb3322232ba22f3bf2223322f73ab12f52f52a1ab332 +Hash of Hello_World!: 0c1c55cb50099c5305199d9500932925530517975755d00b20cc222909550305039275050005905205d7770530c5c0953d50cd9559155729c39101352395c7cc5971b700d925d3d5570500d1c725992c957d500b555950352521dd7b3c505d759d057377005550252b552335d0171071092dd5000959005d53c75170520c5297 +Hash of Hello_World! : 117eb51b771a2557be7fbd710b2231e1e1775227ff13b217e551137e7f55977ddee73e70b0922232a21e773777bb1e155170150172b9713f7f273a3d32737db5ee29af755f75711fb7bf59729efadb12eff722177777e2725e2be7129055075050b55535270302e252213ef752d10b7772b7ba27e5772773732f1f7579777107 +Hash of Hello World: d9ed49a56eea69bc42ce69e89c25bc828bee5d7ece576e6bbb76b94eee779e575daba4be8ece2e8899e2e2bec978b87d7d79a972225e246b687ede897bb556a7e6e8abaebaee6ee282eb45beee4ee5858a8e2e2bcbdbcb84ceee845ee565769cde5ee99958a296e9eee87d774ce82beb8eeaeedceeeb8ec4b8d929e88eebcbea +Hash of Password#123: acae4c46684ec4cefccce6c61c2e6c330fe4fcc8c12cec2004a4acaec3ea2c0448e8ee464ca2ceee6ca2eea62acaa230e6feccaeadcefeec2ee318ccc382ec6c4ecdee46e2cc664ece2eeaeee424c1eee6cece68e2e0e64ee46dfee8ceccc6eccfc26eecc6eeeceee28aa2a41c1f22ac63ee46660ec8c48c2e4ce6aecea4aeea +Hash of AAAAAAAAAAAA: b0a0aa00abba00a80a0aaa0a0b089a0aa8ba080aaaaa0bb00b00909a0aaa08ba0800aa0a000aa0a0baa8a00a8b0a000a80ab0a0aaa0aa09a08a00a8a98aa0000aa0a0abbaa0a080aaaba0b000a0aaa90aaa0ab00aaaaab8a9a90aaa080a0aaaaaa0aa88ab0aaa09a90aa088aa0a0a0aa0a00aa00baaab0aaa808a0aba000a008 +Hash of !#!#!#!#!#!#!#!#: beab626ee6e6b66e666bbea622ae26622efafaee2e2b6ae66eeeeeee22ae6626aea62beeee26eefb222ee622ea6eee66ea66e2ee22e6a66e2ae2666f6ee6fee6e2eeb6226622e2a6e2ebf666ee62a2bb2eeeee6a26eee6e2eeeee262ae2e6afa66e2eee6e66e62e626e2aa22ebbea6ee26e6a2abbe26eee62226eeee6a6b6e62 """ +x = 'Hello Everyone!' +print('Hash works?', hash(x) == hash(x)) # True + +## Encryption -# Encode it so that we have a bytes object to pass to encrypt text = "Hello World!" key = "key" -# Encode it so that we have a bytes object to pass to encrypt - -encoded_text = text.encode() -encoded_key = key.encode() # Encrypt the text -encrypted_bitarray = encrypt(encoded_text, encoded_key) +encrypted_bitarray = encrypt(text, key) print(encrypted_bitarray) print(bitarray_to_text(encrypted_bitarray)) # Decrypt the bitarray -decrypted_bitarray = decrypt(encrypted_bitarray, encoded_key) +decrypted_bitarray = decrypt(encrypted_bitarray, key) # Convert it back to a string. decrypted_text = bitarray_to_text(decrypted_bitarray) print(decrypted_text, text == decrypted_text) # Hello World! True - ``` @@ -70,6 +70,23 @@ print(makeid()) # 3fbe99d84c1b9255565c79d758bebba6e011ba2ca0795c5c50d22519adaf99050e74cb261933091fc4c52d6a7581c3681557e4adf495b1cd1314579e962791efc6d5ceb9133de75cd25a20a99d50cf4b7bf927f61dfa298d69d573da101f26a973241224-a5eb-49fa-828b-f86b89d9a4745480679b-4d20-5b8a-a72b-268877dc086a # ids will vary. ``` -These ids are garunteed to be unique, the chance of collision is about 1 / (2.42721841x10^229). -For refernce, the number of atoms in the universe is estimated to be 10^78. +These ids are garunteed to be unique; the chance of collision is about 1 / (2.42721841x10^229). +For reference, the number of atoms in the universe is estimated to be 10^78. + + +# Documentation: +## PCSS +### `encrypt(data: Union[str, bytes, bitarray], key: Union[str, bytes, bitarray, None]=None, final_key: Union[bitarray, None]=None, rounds=None, salt=None) -> bitarray` +Encrypts data using an advanced method including XOR encrytion and byte and bit reversal. +`salt` will defualt to the key. + +### `decrypt(encrypted_data: Union[str, bytes, bitarray], key: Union[str, bytes, bitarray, None]=None, final_key: Union[bitarray, None]=None, rounds=None, salt=None) -> bitarray` +Decrypts data that was encrypted using the PCSS.encrypt function. Parameters that do not match will generate an incorrect output. + +### `makeid()` +Generates a long and secure id. +These ids are garunteed to be unique; the chance of collision is about 1 / (2.42721841x10^229). +For reference, the number of atoms in the universe is estimated to be 10^78. +## PCSS.hash +### `hash(data: str, length: int = 256, block_size: int = 4) -> str` diff --git a/dist/Projxon Cyber Security System-0.0.3.tar.gz b/dist/Projxon Cyber Security System-0.0.3.tar.gz deleted file mode 100644 index 6306cee..0000000 Binary files a/dist/Projxon Cyber Security System-0.0.3.tar.gz and /dev/null differ diff --git a/dist/Projxon Cyber Security System-0.0.4.tar.gz b/dist/Projxon Cyber Security System-0.0.4.tar.gz deleted file mode 100644 index b3640c7..0000000 Binary files a/dist/Projxon Cyber Security System-0.0.4.tar.gz and /dev/null differ diff --git a/dist/Projxon Cyber Security System-0.0.5.tar.gz b/dist/Projxon Cyber Security System-0.0.5.tar.gz deleted file mode 100644 index c8d78a7..0000000 Binary files a/dist/Projxon Cyber Security System-0.0.5.tar.gz and /dev/null differ diff --git a/dist/Projxon Cyber Security System-0.1.1.tar.gz b/dist/Projxon Cyber Security System-0.1.1.tar.gz deleted file mode 100644 index a2704dc..0000000 Binary files a/dist/Projxon Cyber Security System-0.1.1.tar.gz and /dev/null differ diff --git a/dist/Projxon Cyber Security System-0.1.tar.gz b/dist/Projxon Cyber Security System-0.1.tar.gz deleted file mode 100644 index 68b3284..0000000 Binary files a/dist/Projxon Cyber Security System-0.1.tar.gz and /dev/null differ diff --git a/dist/Projxon_Cyber_Security_System-0.0.3-py3-none-any.whl b/dist/Projxon_Cyber_Security_System-0.0.3-py3-none-any.whl deleted file mode 100644 index b5786ad..0000000 Binary files a/dist/Projxon_Cyber_Security_System-0.0.3-py3-none-any.whl and /dev/null differ diff --git a/dist/Projxon_Cyber_Security_System-0.0.4-py3-none-any.whl b/dist/Projxon_Cyber_Security_System-0.0.4-py3-none-any.whl deleted file mode 100644 index 9055cb1..0000000 Binary files a/dist/Projxon_Cyber_Security_System-0.0.4-py3-none-any.whl and /dev/null differ diff --git a/dist/Projxon_Cyber_Security_System-0.0.5-py3-none-any.whl b/dist/Projxon_Cyber_Security_System-0.0.5-py3-none-any.whl deleted file mode 100644 index c1ba4f3..0000000 Binary files a/dist/Projxon_Cyber_Security_System-0.0.5-py3-none-any.whl and /dev/null differ diff --git a/dist/Projxon_Cyber_Security_System-0.1-py3-none-any.whl b/dist/Projxon_Cyber_Security_System-0.1-py3-none-any.whl deleted file mode 100644 index 73bb081..0000000 Binary files a/dist/Projxon_Cyber_Security_System-0.1-py3-none-any.whl and /dev/null differ diff --git a/dist/Projxon_Cyber_Security_System-0.1.1-py3-none-any.whl b/dist/Projxon_Cyber_Security_System-0.1.1-py3-none-any.whl deleted file mode 100644 index 0b92dc4..0000000 Binary files a/dist/Projxon_Cyber_Security_System-0.1.1-py3-none-any.whl and /dev/null differ diff --git a/dist/projxon_cyber_security_system-0.1.1-py3-none-any.whl b/dist/projxon_cyber_security_system-0.1.1-py3-none-any.whl new file mode 100644 index 0000000..126d133 Binary files /dev/null and b/dist/projxon_cyber_security_system-0.1.1-py3-none-any.whl differ diff --git a/dist/projxon_cyber_security_system-0.1.1.tar.gz b/dist/projxon_cyber_security_system-0.1.1.tar.gz new file mode 100644 index 0000000..4d603ba Binary files /dev/null and b/dist/projxon_cyber_security_system-0.1.1.tar.gz differ diff --git a/main.py b/main.py index 0604b77..fbd3a49 100644 --- a/main.py +++ b/main.py @@ -2,39 +2,40 @@ from PCSS.hash import hash print(f""" -Hash of Hello_World!: {hash("Hello_World!")} -Hash of Hello_World! : {hash("Hello_World! ")} -Hash of Hello World: {hash("Hello World")} -Hash of Password#123: {hash("Password#123")} -Hash of AAAAAAAAAAAA: {hash("AAAAAAAAAAAA")} -Hash of !#!#!#!#!#!#!#!#: {hash("!#!#!#!#!#!#!#!#")} +Hash of Hi!: {hash("Hi!", 256)} +Hash of Hello_World!: {hash("Hello_World!", 256)} +Hash of Hello_World! : {hash("Hello_World! ", 256)} +Hash of Hello World: {hash("Hello World", 256)} +Hash of Password#123: {hash("Password#123", 256)} +Hash of AAAAAAAAAAAA: {hash("AAAAAAAAAAAA", 256)} +Hash of !#!#!#!#!#!#!#!#: {hash("!#!#!#!#!#!#!#!#", 256)} """) + # Output: """ -Hash of Hello_World!: 133e15fbd573507fd63714d032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032fe1032547698badcfe1032 -Hash of Hello_World! : 6ac3ec8eac8ea90aafcaeda5832107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba9854ba98fedc32107654bfeecddc32107654ba98fedc3 -Hash of Hello World: 026b0426c4c941a2c762056789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123ef0123456789abcdef0455766789abcdef012345182439abcdef01234567 -Hash of Password#123: 7ad07a98bc5ffa9e967052b89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd2301cd23016745ab89efcd26775445ab89efcd2301673a061b89efcd230164f5bacd23016745ab89efb -Hash of AAAAAAAAAAAA: 4fa183e5c7290b6d4fa183e56789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab6789abcdef012345678cddfeef0123456789abcd90acb123456789abce5f106789abcdef0123d6e0f789abcdef01234567 -Hash of !#!#!#!#!#!#!#!#: 5a781e34d2f096bc5a781e34d2f096bcdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef23cdef89ab45670123c899baab45670123cdef89d4e8f5670123cdef8a1b5423cdef89ab456792a4b3cdef89ab456700d165ef89ab45670123cdef7067ccc +Hash of Hi!: 32aa253325323f2f7a22f52313272b77335b11b25327aab12772a3522522bf77322223233227222ff2ff3b33332a27252b3ff323127b2335ba752f2a1f3b22122b2b23522522af3f22f522a735f273112332f722b227f122b22111f22222532f75327172332271377a2ffb3322232ba22f3bf2223322f73ab12f52f52a1ab332 +Hash of Hello_World!: 0c1c55cb50099c5305199d9500932925530517975755d00b20cc222909550305039275050005905205d7770530c5c0953d50cd9559155729c39101352395c7cc5971b700d925d3d5570500d1c725992c957d500b555950352521dd7b3c505d759d057377005550252b552335d0171071092dd5000959005d53c75170520c5297 +Hash of Hello_World! : 117eb51b771a2557be7fbd710b2231e1e1775227ff13b217e551137e7f55977ddee73e70b0922232a21e773777bb1e155170150172b9713f7f273a3d32737db5ee29af755f75711fb7bf59729efadb12eff722177777e2725e2be7129055075050b55535270302e252213ef752d10b7772b7ba27e5772773732f1f7579777107 +Hash of Hello World: d9ed49a56eea69bc42ce69e89c25bc828bee5d7ece576e6bbb76b94eee779e575daba4be8ece2e8899e2e2bec978b87d7d79a972225e246b687ede897bb556a7e6e8abaebaee6ee282eb45beee4ee5858a8e2e2bcbdbcb84ceee845ee565769cde5ee99958a296e9eee87d774ce82beb8eeaeedceeeb8ec4b8d929e88eebcbea +Hash of Password#123: acae4c46684ec4cefccce6c61c2e6c330fe4fcc8c12cec2004a4acaec3ea2c0448e8ee464ca2ceee6ca2eea62acaa230e6feccaeadcefeec2ee318ccc382ec6c4ecdee46e2cc664ece2eeaeee424c1eee6cece68e2e0e64ee46dfee8ceccc6eccfc26eecc6eeeceee28aa2a41c1f22ac63ee46660ec8c48c2e4ce6aecea4aeea +Hash of AAAAAAAAAAAA: b0a0aa00abba00a80a0aaa0a0b089a0aa8ba080aaaaa0bb00b00909a0aaa08ba0800aa0a000aa0a0baa8a00a8b0a000a80ab0a0aaa0aa09a08a00a8a98aa0000aa0a0abbaa0a080aaaba0b000a0aaa90aaa0ab00aaaaab8a9a90aaa080a0aaaaaa0aa88ab0aaa09a90aa088aa0a0a0aa0a00aa00baaab0aaa808a0aba000a008 +Hash of !#!#!#!#!#!#!#!#: beab626ee6e6b66e666bbea622ae26622efafaee2e2b6ae66eeeeeee22ae6626aea62beeee26eefb222ee622ea6eee66ea66e2ee22e6a66e2ae2666f6ee6fee6e2eeb6226622e2a6e2ebf666ee62a2bb2eeeee6a26eee6e2eeeee262ae2e6afa66e2eee6e66e62e626e2aa22ebbea6ee26e6a2abbe26eee62226eeee6a6b6e62 """ +x = 'Hello Everyone!' +print('Hash works?', hash(x) == hash(x)) # True + +## Encryption -# Encode it so that we have a bytes object to pass to encrypt text = "Hello World!" key = "key" -# Encode it so that we have a bytes object to pass to encrypt - -encoded_text = text.encode() -encoded_key = key.encode() # Encrypt the text -encrypted_bitarray = encrypt(encoded_text, encoded_key) +encrypted_bitarray = encrypt(text, key) print(encrypted_bitarray) print(bitarray_to_text(encrypted_bitarray)) -# bitarray('00110110101010000111000011100000110100000110001010100110010000101000000000100000101000000010100010001100010011000010010001101100101011001010110011001100100111000010010010000110010011000110101010101100001001000100001011100010110011100111011000101110011000100101111001101010000111000001011010011110111000100001111001011110011011100110110011101010001101100010110001010110001100101111011010011100111100101010111010011100000100100101001001100010010010100111001001011110100111001001011011101100010010100110111001010010110011000100001010000110000100100101101000101100111101101100110000011100110000100100110011110010001011101110110011001100000110101000110001110110111000101111010011110110101011100100101010101100110101101101011000101010110010101011001001110100010001101000101010101100011011001011011001101110100100101010101011001110101011000011011011101100100001101111011001011110010010101010110011101110') # Decrypt the bitarray -decrypted_bitarray = decrypt(encrypted_bitarray, encoded_key) +decrypted_bitarray = decrypt(encrypted_bitarray, key) # Convert it back to a string. decrypted_text = bitarray_to_text(decrypted_bitarray) @@ -45,5 +46,3 @@ print(makeid()) # 3fbe99d84c1b9255565c79d758bebba6e011ba2ca0795c5c50d22519adaf99050e74cb261933091fc4c52d6a7581c3681557e4adf495b1cd1314579e962791efc6d5ceb9133de75cd25a20a99d50cf4b7bf927f61dfa298d69d573da101f26a973241224-a5eb-49fa-828b-f86b89d9a4745480679b-4d20-5b8a-a72b-268877dc086a # ids will vary. - -# These ids are garunteed to be unque, the chance of collision is under 1 / (2^256) diff --git a/output.txt b/output.txt new file mode 100644 index 0000000..7039967 --- /dev/null +++ b/output.txt @@ -0,0 +1,9 @@ + +Hash of Hi!: 32aa253325323f2f7a22f52313272b77335b11b25327aab12772a3522522bf77322223233227222ff2ff3b33332a27252b3ff323127b2335ba752f2a1f3b22122b2b23522522af3f22f522a735f273112332f722b227f122b22111f22222532f75327172332271377a2ffb3322232ba22f3bf2223322f73ab12f52f52a1ab332 +Hash of Hello_World!: 0c1c55cb50099c5305199d9500932925530517975755d00b20cc222909550305039275050005905205d7770530c5c0953d50cd9559155729c39101352395c7cc5971b700d925d3d5570500d1c725992c957d500b555950352521dd7b3c505d759d057377005550252b552335d0171071092dd5000959005d53c75170520c5297 +Hash of Hello_World! : 117eb51b771a2557be7fbd710b2231e1e1775227ff13b217e551137e7f55977ddee73e70b0922232a21e773777bb1e155170150172b9713f7f273a3d32737db5ee29af755f75711fb7bf59729efadb12eff722177777e2725e2be7129055075050b55535270302e252213ef752d10b7772b7ba27e5772773732f1f7579777107 +Hash of Hello World: d9ed49a56eea69bc42ce69e89c25bc828bee5d7ece576e6bbb76b94eee779e575daba4be8ece2e8899e2e2bec978b87d7d79a972225e246b687ede897bb556a7e6e8abaebaee6ee282eb45beee4ee5858a8e2e2bcbdbcb84ceee845ee565769cde5ee99958a296e9eee87d774ce82beb8eeaeedceeeb8ec4b8d929e88eebcbea +Hash of Password#123: acae4c46684ec4cefccce6c61c2e6c330fe4fcc8c12cec2004a4acaec3ea2c0448e8ee464ca2ceee6ca2eea62acaa230e6feccaeadcefeec2ee318ccc382ec6c4ecdee46e2cc664ece2eeaeee424c1eee6cece68e2e0e64ee46dfee8ceccc6eccfc26eecc6eeeceee28aa2a41c1f22ac63ee46660ec8c48c2e4ce6aecea4aeea +Hash of AAAAAAAAAAAA: b0a0aa00abba00a80a0aaa0a0b089a0aa8ba080aaaaa0bb00b00909a0aaa08ba0800aa0a000aa0a0baa8a00a8b0a000a80ab0a0aaa0aa09a08a00a8a98aa0000aa0a0abbaa0a080aaaba0b000a0aaa90aaa0ab00aaaaab8a9a90aaa080a0aaaaaa0aa88ab0aaa09a90aa088aa0a0a0aa0a00aa00baaab0aaa808a0aba000a008 +Hash of !#!#!#!#!#!#!#!#: beab626ee6e6b66e666bbea622ae26622efafaee2e2b6ae66eeeeeee22ae6626aea62beeee26eefb222ee622ea6eee66ea66e2ee22e6a66e2ae2666f6ee6fee6e2eeb6226622e2a6e2ebf666ee62a2bb2eeeee6a26eee6e2eeeee262ae2e6afa66e2eee6e66e62e626e2aa22ebbea6ee26e6a2abbe26eee62226eeee6a6b6e62 + diff --git a/projxon_cyber_security_system.egg-info/PKG-INFO b/projxon_cyber_security_system.egg-info/PKG-INFO new file mode 100644 index 0000000..6839f2d --- /dev/null +++ b/projxon_cyber_security_system.egg-info/PKG-INFO @@ -0,0 +1,90 @@ +Metadata-Version: 2.1 +Name: projxon-cyber-security-system +Version: 0.1.1 +Summary: A fast and unbreakable encrytion system. +Download-URL: https://github.com/hg0428/Projxon-Cyber-Security-System/archive/refs/tags/stable-0.1.1.tar.gz +Author: Hudson Gouge +Classifier: Intended Audience :: Developers +Classifier: Topic :: Software Development :: Build Tools +Classifier: Programming Language :: Python :: 3 +Classifier: License :: OSI Approved :: MIT License +Classifier: Operating System :: OS Independent +Requires-Python: >=3.7 +Description-Content-Type: text/markdown +License-File: LICENSE.txt + +# What is it? +A fast and unbreakable encrytion system. +This library has 4 functions, `makeid`, `encrypt`, `decrypt`, and `bitarray_to_text`. + +`makeid` will generate a long, virtually collision-proof identifier. + +These tools can be very useful in login systems. + +It also includes a (probably insecure) custom hash function in `PCSS.hash`. +# Installation +You can install it with pip. +`pip install Projxon-Cyber-Security-System` + + +# Usage + +## Encyrpt and Decrypt +```py +from PCSS import encrypt, decrypt, makeid, bitarray_to_text +from PCSS.hash import hash + +print(f""" +Hash of Hello_World!: {hash("Hello_World!")} +Hash of Hello_World! : {hash("Hello_World! ")} +Hash of Hello World: {hash("Hello World")} +Hash of Password#123: {hash("Password#123")} +Hash of AAAAAAAAAAAA: {hash("AAAAAAAAAAAA")} +Hash of !#!#!#!#!#!#!#!#: {hash("!#!#!#!#!#!#!#!#")} +""") +# Output: +""" +Hash of Hello_World!: 133e15fbd573507fd63714d032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032547698badcfe1032fe1032547698badcfe1032 +Hash of Hello_World! : 6ac3ec8eac8ea90aafcaeda5832107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba98fedc32107654ba9854ba98fedc32107654bfeecddc32107654ba98fedc3 +Hash of Hello World: 026b0426c4c941a2c762056789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123ef0123456789abcdef0455766789abcdef012345182439abcdef01234567 +Hash of Password#123: 7ad07a98bc5ffa9e967052b89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd23016745ab89efcd2301cd23016745ab89efcd26775445ab89efcd2301673a061b89efcd230164f5bacd23016745ab89efb +Hash of AAAAAAAAAAAA: 4fa183e5c7290b6d4fa183e56789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789ab6789abcdef012345678cddfeef0123456789abcd90acb123456789abce5f106789abcdef0123d6e0f789abcdef01234567 +Hash of !#!#!#!#!#!#!#!#: 5a781e34d2f096bc5a781e34d2f096bcdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef89ab45670123cdef23cdef89ab45670123c899baab45670123cdef89d4e8f5670123cdef8a1b5423cdef89ab456792a4b3cdef89ab456700d165ef89ab45670123cdef7067ccc +""" + +# Encode it so that we have a bytes object to pass to encrypt +text = "Hello World!" +key = "key" +# Encode it so that we have a bytes object to pass to encrypt + +encoded_text = text.encode() +encoded_key = key.encode() + +# Encrypt the text +encrypted_bitarray = encrypt(encoded_text, encoded_key) +print(encrypted_bitarray) +print(bitarray_to_text(encrypted_bitarray)) + +# Decrypt the bitarray +decrypted_bitarray = decrypt(encrypted_bitarray, encoded_key) + +# Convert it back to a string. +decrypted_text = bitarray_to_text(decrypted_bitarray) + +print(decrypted_text, text == decrypted_text) +# Hello World! True + +``` + + +## Generate id +```py +from PCSS import makeid + +print(makeid()) +# 3fbe99d84c1b9255565c79d758bebba6e011ba2ca0795c5c50d22519adaf99050e74cb261933091fc4c52d6a7581c3681557e4adf495b1cd1314579e962791efc6d5ceb9133de75cd25a20a99d50cf4b7bf927f61dfa298d69d573da101f26a973241224-a5eb-49fa-828b-f86b89d9a4745480679b-4d20-5b8a-a72b-268877dc086a +# ids will vary. +``` +These ids are garunteed to be unique, the chance of collision is about 1 / (2.42721841x10^229). +For refernce, the number of atoms in the universe is estimated to be 10^78. + diff --git a/projxon_cyber_security_system.egg-info/SOURCES.txt b/projxon_cyber_security_system.egg-info/SOURCES.txt new file mode 100644 index 0000000..ff3dc83 --- /dev/null +++ b/projxon_cyber_security_system.egg-info/SOURCES.txt @@ -0,0 +1,12 @@ +LICENSE.txt +README.md +pyproject.toml +setup.cfg +setup.py +/home/runner/Projxon-Cyber-Security-System/PCSS/__init__.py +/home/runner/Projxon-Cyber-Security-System/PCSS/hash.py +/home/runner/Projxon-Cyber-Security-System/projxon_cyber_security_system.egg-info/PKG-INFO +/home/runner/Projxon-Cyber-Security-System/projxon_cyber_security_system.egg-info/SOURCES.txt +/home/runner/Projxon-Cyber-Security-System/projxon_cyber_security_system.egg-info/dependency_links.txt +/home/runner/Projxon-Cyber-Security-System/projxon_cyber_security_system.egg-info/requires.txt +/home/runner/Projxon-Cyber-Security-System/projxon_cyber_security_system.egg-info/top_level.txt \ No newline at end of file diff --git a/Projxon_Cyber_Security_System.egg-info/dependency_links.txt b/projxon_cyber_security_system.egg-info/dependency_links.txt similarity index 100% rename from Projxon_Cyber_Security_System.egg-info/dependency_links.txt rename to projxon_cyber_security_system.egg-info/dependency_links.txt diff --git a/Projxon_Cyber_Security_System.egg-info/requires.txt b/projxon_cyber_security_system.egg-info/requires.txt similarity index 100% rename from Projxon_Cyber_Security_System.egg-info/requires.txt rename to projxon_cyber_security_system.egg-info/requires.txt diff --git a/Projxon_Cyber_Security_System.egg-info/top_level.txt b/projxon_cyber_security_system.egg-info/top_level.txt similarity index 100% rename from Projxon_Cyber_Security_System.egg-info/top_level.txt rename to projxon_cyber_security_system.egg-info/top_level.txt diff --git a/setup.py b/setup.py index 1ace666..5c3f330 100644 --- a/setup.py +++ b/setup.py @@ -1,29 +1,30 @@ import setuptools with open("README.md", "r") as fh: - long_description = fh.read() + long_description = fh.read() setuptools.setup( - name="Projxon Cyber Security System", # This is the name of the package - version="0.1.1", # The initial release version - author="Hudson Gouge", # Full name of the author - description="A fast and unbreakable encrytion system.", - long_description= - long_description, # Long description read from the the readme file - long_description_content_type="text/markdown", - packages=setuptools.find_packages( - ), # List of all python modules to be installed - download_url= - 'https://github.com/hg0428/Projxon-Cyber-Security-System/archive/refs/tags/stable-0.1.1.tar.gz', - classifiers=[ - 'Intended Audience :: Developers', # Define that your audience are developers - 'Topic :: Software Development :: Build Tools', - "Programming Language :: Python :: 3", - "License :: OSI Approved :: MIT License", - "Operating System :: OS Independent", - ], # Information to filter the project on PyPi website - python_requires='>=3.7', # Minimum version requirement of the package - py_modules=["PCSS"], # Name of the python package - package_dir={'': '/home/runner/Projxon-Cyber-Security-System/' - }, # Directory of the source code of the package - install_requires=['bitarray', 'passlib']) + name="projxon_cyber_security_system", # This is the name of the package + version="0.1.1", # The initial release version + author="Hudson Gouge", # Full name of the author + description="A fast and unbreakable encrytion system.", + long_description= + long_description, # Long description read from the the readme file + long_description_content_type="text/markdown", + packages=setuptools.find_packages( + ), # List of all python modules to be installed + download_url= + 'https://github.com/hg0428/Projxon-Cyber-Security-System/archive/refs/tags/stable-0.1.1.tar.gz', + classifiers=[ + 'Intended Audience :: Developers', # Define that your audience are developers + 'Topic :: Software Development :: Build Tools', + "Programming Language :: Python :: 3", + "License :: OSI Approved :: MIT License", + "Operating System :: OS Independent", + ], # Information to filter the project on PyPi website + python_requires='>=3.7', # Minimum version requirement of the package + py_modules=["PCSS"], # Name of the python package + package_dir={'': '/home/runner/Projxon-Cyber-Security-System/' + }, # Directory of the source code of the package + install_requires=['bitarray', 'passlib'], +strict_naming=False)