Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
hg0428 authored Nov 19, 2023
1 parent f9bb89b commit 564bb0c
Showing 1 changed file with 27 additions and 11 deletions.
38 changes: 27 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# What is it?
A fast and unbreakable encrytion system.
This library has 3 functions, `makeid`, `encrypt`, and `decrypt`.
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`
Expand All @@ -15,34 +16,49 @@ You can install it with pip.

## Encyrpt and Decrypt
```py
from PCSS import encrypt, decrypt
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)
# bitarray('00110110101010000111000011100000110100000110001010100110010000101000000000100000101000000010100010001100010011000010010001101100101011001010110011001100100111000010010010000110010011000110101010101100001001000100001011100010110011100111011000101110011000100101111001101010000111000001011010011110111000100001111001011110011011100110110011101010001101100010110001010110001100101111011010011100111100101010111010011100000100100101001001100010010010100111001001011110100111001001011011101100010010100110111001010010110011000100001010000110000100100101101000101100111101101100110000011100110000100100110011110010001011101110110011001100000110101000110001110110111000101111010011110110101011100100101010101100110101101101011000101010110010101011001001110100010001101000101010101100011011001011011001101110100100101010101011001110101011000011011011101100100001101111011001011110010010101010110011101110')
print(bitarray_to_text(encrypted_bitarray))

# Decrypt the bitarray
decrypted_bitarray = decrypt(encrypted_bitarray, encoded_key)

# Change it back into bytes
decrypted_bytes = decrypted_bitarray.tobytes()
# Convert it back to a string.
decrypted_text = bitarray_to_text(decrypted_bitarray)

# Remove the trailing 0s and convert to string
decrypted_text = decrypted_bytes.rstrip(b'\x00').decode()

print(decrypted_text, text == decrypted_text)
print(decrypted_text, text == decrypted_text)
# Hello World! True

```


Expand Down

0 comments on commit 564bb0c

Please sign in to comment.