diff --git a/.github/workflows/codacy-analysis.yml b/.github/workflows/codacy-analysis.yml
index 779edd2..6811c47 100644
--- a/.github/workflows/codacy-analysis.yml
+++ b/.github/workflows/codacy-analysis.yml
@@ -10,7 +10,7 @@ name: Codacy Security Scan
on:
push:
- branches: [ main, passlib_addition]
+ branches: [ main, passlib_addition, fixes]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
index d8a3cb5..254ce5e 100644
--- a/.github/workflows/codeql-analysis.yml
+++ b/.github/workflows/codeql-analysis.yml
@@ -13,7 +13,7 @@ name: "CodeQL"
on:
push:
- branches: [ main, passlib_addition ]
+ branches: [ main, passlib_addition, fixes]
pull_request:
# The branches below must be a subset of the branches above
branches: [ main ]
diff --git a/.github/workflows/devskim-analysis.yml b/.github/workflows/devskim-analysis.yml
index 5d65aad..e13fd36 100644
--- a/.github/workflows/devskim-analysis.yml
+++ b/.github/workflows/devskim-analysis.yml
@@ -7,7 +7,7 @@ name: DevSkim
on:
push:
- branches: [ main, passlib_addition ]
+ branches: [ main, passlib_addition, fixes]
pull_request:
branches: [ main ]
schedule:
diff --git a/README.md b/README.md
index b4977a3..ceacfc6 100644
--- a/README.md
+++ b/README.md
@@ -21,12 +21,34 @@ After Following All The Steps Mentioned Above (If You Don't Get An Error) EnroCr
```python
# For Encryption
from enrocrypt import core
- value = core.Encrypt(b'text')
+ obj = core.Core()
+ value = obj.Encrypt(b'text')
print(value)
# For Decryption
- original_value = core.DecryptList(value)
+ original_value = obj.DecryptList(value)
print(original_value)
```
There Is Also a `Decrypt`Function, But In This Function You Have To Enter The Key And The Data Seperatly
-
+## Adding Configurations
+Enrocrypt Has The Ablity To Adopt Custom Configurations, Namely:- Custom Salt
+We Provide A Function In Which You Can Pass All The Configurations But It Also Has A Syntax And Must Be Used "As is"
+```python
+from enrocrypt import core
+config = {
+ 'configs':{
+ 'salt_file':"The Path Of The File Where Your Salt Is Stored"
+ }
+ }
+ # You need a Core Class Object to access that function
+ obj = core.Core()
+ obj.set_config(config)
+```
+## Getting A Hashing Class Object
+We Suggest Not To Use The Hashing Class By Importing It Directly As If You Do So You Can't Add Your Custom Salt
+To Add Custom Salt Follow The `Adding Configuration`. After You Did That You Have To Get A Hasing Class Object By A Core Class Function
+```python
+from enrocrypt import core
+obj = core.Core()
+hasing_obj = obj.get_hash_object()
+```
(See Discussion For More Info)
diff --git a/enrocrypt/basic.py b/enrocrypt/basic.py
index 4579805..8ec1924 100644
--- a/enrocrypt/basic.py
+++ b/enrocrypt/basic.py
@@ -1,7 +1,8 @@
-from enrocrypt import error
import uuid, os
+from enrocrypt import error
class Basic():
+ '''This Class Consists of all the basic functions that can be useful'''
def __str__(self) -> str:
return "This Class Has All the Basic Functions Of EnroCrypt"
def seperator(self,data: str):
@@ -47,7 +48,7 @@ def to_str(self,data):
in_ascii.append(int(in_int[i],16))
for i,_ in enumerate(in_ascii):
in_str.append(chr(in_ascii[i]))
- return(in_str)
+ return in_str
def Sign(self,sign:str):
'''A Hint Of Upcomming Updates'''
diff --git a/enrocrypt/core.py b/enrocrypt/core.py
index e80ebc3..75edc0f 100644
--- a/enrocrypt/core.py
+++ b/enrocrypt/core.py
@@ -30,6 +30,7 @@ def __Set_Salt(self,salt:list):
else:
return False
def get_hash_object(self):
+ '''Returns A Hashing Class Object That Is Pre-Configured To Use Custom Salt If Any'''
hashing = Hashing()
if self.salt == "":
print(print(Warning("No Personalized Salt Loaded In The Memory, Using Random Salt")))
diff --git a/enrocrypt/error.py b/enrocrypt/error.py
index 2e54656..4fef5cd 100644
--- a/enrocrypt/error.py
+++ b/enrocrypt/error.py
@@ -2,20 +2,25 @@ class ModifiedError(Exception):
def __init__(self):
self.msg = 'The List Provided To The Function Is Modified'
super().__init__(self.msg)
+ exit()
class ListIndexError(Exception):
def __init__(self):
self.msg = 'Returned List Must Only Have 4 Elements'
super().__init__(self.msg)
+ exit()
class NoKeyFile(Exception):
def __init__(self):
self.msg = 'No Path For The Key File was Provided'
super().__init__(self.msg)
+ exit()
class List(Exception):
- def __init__(self):
- self.msg = "Must Be A List"
- super().__init__(self.msg)
+ def __init__(self):
+ self.msg = "Must Be A List"
+ super().__init__(self.msg)
+ exit()
class KeyError(Exception):
def __init__(self,bits:int) -> None:
self.bits = bits
self.msg = f"Key Must Be Of 32, 24 or 16 bits not {self.bits} bits"
- super().__init__(self.msg)
\ No newline at end of file
+ super().__init__(self.msg)
+ exit()
\ No newline at end of file
diff --git a/enrocrypt/hashing.py b/enrocrypt/hashing.py
index 5d66ba4..1923a7a 100644
--- a/enrocrypt/hashing.py
+++ b/enrocrypt/hashing.py
@@ -1,4 +1,4 @@
-import hashlib, base64, uuid
+import hashlib, base64, uuid, passlib
from cryptography.hazmat.primitives import hashes
from typing import Any
class Hashing():
@@ -10,26 +10,6 @@ def __call__(self, *args:Any):
def __str__(self):
return "Hashing Funcitions In Here"
- def Standard_Multi_Hash(self,Data:str):
- '''Inreversable Salted Hash Function Don't Use If U Want To Get The Content Back'''
- a = hashlib.sha256(); a.update(bytes(Data.encode())); b = []
- base = hashlib.sha512()
- md = hashlib.md5()
- b.append(str(a.digest()).split("'")[1])
- b[0] = str(base64.urlsafe_b64encode(bytes(b[0].encode()))).split("'")[1]
- base.update(bytes(b[0].encode()))
- md.update(base.digest())
- b[0]=str(base64.urlsafe_b64encode(base64.standard_b64encode(md.digest()))).split("'")[1]
- salt = ['H', 'c', 'D', 'L', 'b', 'M', 'S', 'a', 'N', 'q', 'K', 'j', 'V', 'd', 'O', 'W', 'x']
- c = (b[0].split("G"))or(b[0].split("g"))or(b[0].split("v"))or(b[0].split("x")); d=[]; e=[]
- for i in range(len(c)): a = salt[i]; b = c[i]; c[i] = b+a
- for i in range(len(c)):
- try: d.append(c[i+1])
- except: d.append(c[0])
- e.append(''.join(d))
- final = self.BLAKE2(bytes(str(e[0]).encode()))
- return(final)
-
def __Salt(self,data,salt:bytes = None):
if not salt:
salts = []
@@ -57,16 +37,32 @@ def __Salt(self,data,salt:bytes = None):
if salting2 > self.byt:
salting2 = salting2.decode()[0:self.byt]
return salting2
-
+
+ def Standard_Multi_Hash(self,Data:str):
+ '''Inreversable Salted Hash Function Don't Use If U Want To Get The Content Back'''
+ a = hashlib.sha256(); a.update(bytes(Data.encode())); b = []
+ base = hashlib.sha512()
+ md = hashlib.md5()
+ b.append(str(a.digest()).split("'")[1])
+ b[0] = str(base64.urlsafe_b64encode(bytes(b[0].encode()))).split("'")[1]
+ base.update(bytes(b[0].encode()))
+ md.update(base.digest())
+ b[0]=str(base64.urlsafe_b64encode(base64.standard_b64encode(md.digest()))).split("'")[1]
+ salt = ['H', 'c', 'D', 'L', 'b', 'M', 'S', 'a', 'N', 'q', 'K', 'j', 'V', 'd', 'O', 'W', 'x']
+ c = (b[0].split("G"))or(b[0].split("g"))or(b[0].split("v"))or(b[0].split("x")); d=[]
+ d[0] = self.__Salt(c,salt=self.salt)
+ final = self.BLAKE2(bytes(str(d[0]).encode()))
+ return(final)
+
def SHA256(self,data:str):
sha = hashlib.sha256(bytes(data.encode()))
- hash = sha.digest()
- return self.__Salt(hash,salt=self.salt)
+ Hash = sha.digest()
+ return self.__Salt(Hash,salt=self.salt)
def SHA512(self,data:str):
sha = hashlib.sha512(bytes(data.encode()))
- hash = str(sha.digest())
- return self.__Salt(hash,salt=self.salt)
+ Hash = str(sha.digest())
+ return self.__Salt(Hash,salt=self.salt)
def SHA244(self,data:str):
sha = hashlib.sha224(bytes(data.encode()))
@@ -75,10 +71,10 @@ def SHA244(self,data:str):
def SHA384(self,data:str):
sha = hashlib.sha384(bytes(data.encode()))
- hash = str(sha.digest())
- return self.__Salt(hash,salt=self.salt)
+ Hash = str(sha.digest())
+ return self.__Salt(Hash,salt=self.salt)
def BLAKE2(self,data:bytes):
a = hashes.Hash(hashes.BLAKE2s(32))
a.update(data)
- return self.__Salt(a.finalize(),salt=self.salt)
\ No newline at end of file
+ return self.__Salt(a.finalize(),salt=self.salt)
diff --git a/enrocrypt/key.py b/enrocrypt/key.py
index ed05d3b..1382320 100644
--- a/enrocrypt/key.py
+++ b/enrocrypt/key.py
@@ -1,7 +1,6 @@
from cryptography.hazmat.primitives.hashes import SHA256
from cryptography.hazmat.primitives.kdf.hkdf import HKDF
from enrocrypt.hashing import Hashing
-from enrocrypt.encryption import Encryption
from enrocrypt.error import KeyError
def generate_key(words:str,salt:bytes,bits:int = 32):
diff --git a/setup.py b/setup.py
index 1ae2f54..2270802 100644
--- a/setup.py
+++ b/setup.py
@@ -2,9 +2,8 @@
file = open('README.md','r').read()
setup(
name="enrocrypt",
- version="1.1.3",
+ version="1.1.4",
author="Morgan-Phoenix",
- author_email="mikebrain61@gmail.com",
description="This is a Python Module For Encryption, Hashing And Other stuff",
long_description=file,
long_description_content_type="text/markdown",
@@ -18,6 +17,6 @@
"Operating System :: OS Independent",
],
packages=find_packages(),
- install_requires=['cryptography'],
+ install_requires=['cryptography', 'passlib'],
python_requires=">=3.6",
)
\ No newline at end of file