-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added core.py * Added The Option Of Custom Salt * warped Everything In Classes Now Just Import Core from enrocrypt.core and User Can Use All Functions.
- Loading branch information
1 parent
4225db6
commit efe3e66
Showing
4 changed files
with
279 additions
and
212 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,57 @@ | ||
from enrocrypt import error | ||
import uuid, os | ||
def seperator(data: str): | ||
'''Takes a String and Returns a List of the Characters. All Elements of the List are str. The List is Iterable.''' | ||
strData = str(data) # To avoid errors | ||
listString = list(strData) | ||
return listString | ||
|
||
def hexdigest(data:bytes): | ||
'''Returns A Wrong Hex Value. Must Only Be Used With Hashing Functions As The Hex Data Is Hard To Retrive''' | ||
to_ascii = seperator(data) | ||
in_ascii = [] | ||
in_str_ascii = [] | ||
for i in to_ascii: | ||
in_ascii.append(ord(i)) | ||
for i in in_ascii: | ||
in_str_ascii.append(str(i)) | ||
to_hex = int(''.join(in_str_ascii)) | ||
in_hex = hex(to_hex) | ||
return in_hex | ||
class Basic(): | ||
def __str__(self) -> str: | ||
return "This Class Has All the Basic Functions Of EnroCrypt" | ||
def seperator(self,data: str): | ||
'''Takes a String and Returns a List of the Characters. All Elements of the List are str. The List is Iterable.''' | ||
strData = str(data) # To avoid errors | ||
listString = list(strData) | ||
return listString | ||
|
||
def Hex(data): | ||
'''Gives The Correct Value With Each Group Of Letter(s) Representing A Character | ||
When Decoded Gives Integer. The Returned Value Will Have One More Layer Of Abstruction''' | ||
to_ascii = seperator(data) | ||
in_ascii = [] | ||
in_hex = [] | ||
for i in to_ascii: | ||
in_ascii.append(ord(i)) | ||
for i in in_ascii: | ||
in_hex.append(hex(i)) | ||
return in_hex | ||
def to_str(data): | ||
'''Takes The List Returned By Hex Function''' | ||
if type(data) != type([]): | ||
error.List() | ||
in_int = [] | ||
in_ascii = [] | ||
in_str = [] | ||
for i,_ in enumerate(data): | ||
in_int.append(data[i]) | ||
for i,_ in enumerate(in_int): | ||
in_ascii.append(int(in_int[i],16)) | ||
for i,_ in enumerate(in_ascii): | ||
in_str.append(chr(in_ascii[i])) | ||
return(in_str) | ||
def hexdigest(self,data:bytes): | ||
'''Returns A Wrong Hex Value. Must Only Be Used With Hashing Functions As The Hex Data Is Hard To Retrive''' | ||
to_ascii = self.seperator(data) | ||
in_ascii = [] | ||
in_str_ascii = [] | ||
for i in to_ascii: | ||
in_ascii.append(ord(i)) | ||
for i in in_ascii: | ||
in_str_ascii.append(str(i)) | ||
to_hex = int(''.join(in_str_ascii)) | ||
in_hex = hex(to_hex) | ||
return in_hex | ||
|
||
def Sign(sign:str): | ||
'''A Hint Of Upcomming Updates''' | ||
return uuid.uuid5(uuid.uuid4(),sign) | ||
def Password_Creator(): | ||
'''This Password Generator Is For The Function Auth_Encryption. NOT for Generating Account Passwords''' | ||
return os.urandom(12) | ||
def Hex(self,data): | ||
'''Gives The Correct Value With Each Group Of Letter(s) Representing A Character | ||
When Decoded Gives Integer. The Returned Value Will Have One More Layer Of Abstruction''' | ||
to_ascii = self.seperator(data) | ||
in_ascii = [] | ||
in_hex = [] | ||
for i in to_ascii: | ||
in_ascii.append(ord(i)) | ||
for i in in_ascii: | ||
in_hex.append(hex(i)) | ||
return in_hex | ||
def to_str(self,data): | ||
'''Takes The List Returned By Hex Function''' | ||
if type(data) != type([]): | ||
error.List() | ||
in_int = [] | ||
in_ascii = [] | ||
in_str = [] | ||
for i,_ in enumerate(data): | ||
in_int.append(data[i]) | ||
for i,_ in enumerate(in_int): | ||
in_ascii.append(int(in_int[i],16)) | ||
for i,_ in enumerate(in_ascii): | ||
in_str.append(chr(in_ascii[i])) | ||
return(in_str) | ||
|
||
def Sign(self,sign:str): | ||
'''A Hint Of Upcomming Updates''' | ||
return uuid.uuid5(uuid.uuid4(),sign) | ||
def Password_Creator(self): | ||
'''This Password Generator Is For The Function Auth_Encryption. NOT for Generating Account Passwords''' | ||
return os.urandom(12) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from typing import Any | ||
from hashing import Hashing | ||
from encryption import Encryption | ||
from basic import Basic | ||
|
||
class Core(Hashing,Encryption,Basic): | ||
'''Given Below Is The Syntax To Set Configurations For This Class. This Must Be Used As Is(Just Change The File Path) | ||
config = { | ||
'configs':{ | ||
'salt_file':"The Path Of The File Where Your Salt Is Stored" | ||
} | ||
}''' | ||
def __init__(self) -> None: | ||
self.salt = '' | ||
def __call__(self,*args: Any): | ||
configs = (args[0]['configs']['salt_file']) | ||
value = self.__Set_Salt(configs) | ||
return value | ||
def __str__(self) -> str: | ||
return "The Base Class Of EnroCrypt" | ||
def __Set_Salt(self,salt:list): | ||
try: | ||
with open(salt,'r') as f: | ||
salts = f.read() | ||
self.salt = bytes(salts.encode()) | ||
return True | ||
except FileNotFoundError: | ||
return Warning("No Salt File Found At The Given Location Using Random Salt") | ||
else: | ||
return False | ||
def get_hash_object(self): | ||
hashing = Hashing() | ||
hashing(bytes(self.salt.encode())) | ||
return hashing | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.