Skip to content

Commit

Permalink
bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
hg0428 committed Jan 28, 2024
1 parent dd74bf0 commit 3f714ed
Show file tree
Hide file tree
Showing 14 changed files with 25 additions and 20 deletions.
3 changes: 2 additions & 1 deletion PCSS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def process_key(key: Union[str, bytes, bitarray, int, None],
"""
Process a key for encryption or decryption
"""
key = to_bitarray(key)
final_key = bitarray()
if rounds == None:
rounds = (int(key[:15].to01(), 2) + 100) * 2
Expand All @@ -45,7 +46,7 @@ def encrypt(data: Union[str, bytes, bitarray, int],
raise ValueError("Either key OR final_key must be provided.")
else:
key = to_bitarray(key)
final_key = process_key(key, salt, rounds)
final_key = process_key(key, salt, rounds)
if len(final_key) > len(data):
final_key = final_key[-len(data):]
while len(final_key) < len(data):
Expand Down
30 changes: 18 additions & 12 deletions build/lib/PCSS/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@
uuid5(uuid4(), str(uuid1())))


def process_key(key: Union[str, bytes, bitarray, int, None],
salt=None,
rounds=None) -> bitarray:
"""
Process a key for encryption or decryption
"""
final_key = bitarray()
if rounds == None:
rounds = (int(key[:15].to01(), 2) + 100) * 2
x = pbkdf2_sha512.hash(key.tobytes(),
rounds=rounds,
salt=salt if salt else key.tobytes()).split('$')[-1]
final_key.frombytes(ab64_decode(x))
return final_key


def encrypt(data: Union[str, bytes, bitarray, int],
key: Union[str, bytes, bitarray, int, None] = None,
final_key: Union[bitarray, None] = None,
Expand All @@ -29,13 +45,7 @@ def encrypt(data: Union[str, bytes, bitarray, int],
raise ValueError("Either key OR final_key must be provided.")
else:
key = to_bitarray(key)
final_key = bitarray()
if rounds == None:
rounds = (int(key[:15].to01(), 2) + 100) * 2
x = pbkdf2_sha512.hash(key.tobytes(),
rounds=rounds,
salt=salt if salt else key.tobytes()).split('$')[-1]
final_key.frombytes(ab64_decode(x))
final_key = process_key(key, salt, rounds)
if len(final_key) > len(data):
final_key = final_key[-len(data):]
while len(final_key) < len(data):
Expand All @@ -62,11 +72,7 @@ def decrypt(encrypted_data: Union[str, bytes, bitarray, int],
key = to_bitarray(key)
if rounds == None:
rounds = (int(key[:15].to01(), 2) + 100) * 2
final_key = bitarray()
x = pbkdf2_sha512.hash(key.tobytes(),
rounds=rounds,
salt=salt if salt else key.tobytes()).split('$')[-1]
final_key.frombytes(ab64_decode(x))
final_key = process_key(key, salt, rounds)
encrypted_data.reverse()
encrypted_data.bytereverse()
if len(final_key) > len(encrypted_data):
Expand Down
Binary file not shown.
Binary file removed dist/projxon_cyber_security_system-0.1.1.tar.gz
Binary file not shown.
Binary file not shown.
Binary file removed dist/projxon_cyber_security_system-0.2.1.tar.gz
Binary file not shown.
Binary file not shown.
Binary file removed dist/projxon_cyber_security_system-0.3.0.tar.gz
Binary file not shown.
Binary file not shown.
Binary file added dist/projxon_cyber_security_system-0.3.3.tar.gz
Binary file not shown.
Empty file modified make
100644 → 100755
Empty file.
4 changes: 2 additions & 2 deletions projxon_cyber_security_system.egg-info/PKG-INFO
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
Metadata-Version: 2.1
Name: projxon-cyber-security-system
Version: 0.3.0
Version: 0.3.3
Summary: A fast and unbreakable encrytion system.
Download-URL: https://github.com/hg0428/Projxon-Cyber-Security-System/archive/refs/tags/stable-0.3.tar.gz
Download-URL: https://github.com/hg0428/Projxon-Cyber-Security-System/archive/refs/tags/stable-0.3.1.tar.gz
Author: Hudson Gouge
Classifier: Intended Audience :: Developers
Classifier: Topic :: Software Development :: Build Tools
Expand Down
2 changes: 0 additions & 2 deletions projxon_cyber_security_system.egg-info/requires.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
bitarray
passlib
hashlib
base64
uuid
6 changes: 3 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="projxon_cyber_security_system", # This is the name of the package
version="0.3.1", # The release version
version="0.3.4", # The release version
author="Hudson Gouge", # Full name of the author
description="A fast and unbreakable encrytion system.",
long_description=
Expand All @@ -14,7 +14,7 @@
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.3.1.tar.gz',
'https://github.com/hg0428/Projxon-Cyber-Security-System/archive/refs/tags/stable-0.3.4.tar.gz',
classifiers=[
'Intended Audience :: Developers', # Define that your audience are developers
'Topic :: Software Development :: Build Tools',
Expand All @@ -26,4 +26,4 @@
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', 'hashlib', 'base64', 'uuid'])
install_requires=['bitarray', 'passlib', 'uuid'])

0 comments on commit 3f714ed

Please sign in to comment.