Skip to content

Commit

Permalink
v1.0.1 Ready
Browse files Browse the repository at this point in the history
  • Loading branch information
metamorphic-spyware committed May 26, 2021
1 parent 7a78bd4 commit 34bf2de
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 3 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
This is a Python Module For Encryption, Hashing And Other Basic Stuff You Need, With Secure Encryption And Strong Salted Hashing You Can Do Whatever You Want To
## Installation
EnroCrypt Is Avaliable On <a style="text-decoration:none;" herf="https://pypi.org/projects/enrocrypt">PyPi </a>You Can Install It As Follows:<br>
```$ pip -m install enrocrypt```
```$ pip install -U enrocrypt```
## Manual Installation
If For Some Reason You Can't Install EnroCrypt From PyPi You Can Download It Manually Too:
* Clone This Repo
Expand All @@ -14,6 +14,7 @@ After Following All The Steps Mentioned Above (If You Don't Get An Error) EnroCr
## Features
* Strong Encryption
* Strong Salted Hashing
* File Encryption-Decryption
* Some Basic Functions
## Usage
```python
Expand Down
43 changes: 41 additions & 2 deletions enrocrypt/encryption.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .error import Error
from enrocrypt.error import Error
def _Keyencryption(key:bytes):
import base64
bases = base64.standard_b64encode(key)
Expand Down Expand Up @@ -54,4 +54,43 @@ def Decrypt_List(Data:list):
d_key = _Keydecryption(Key)
d_data = _datadecryption(e_Data)
based = _BaseDecryption(d_key,d_data)
return based
return based
def FileEncryption(Path:str,KeyFilePath:str):
'''Make Sure The Path You Give Has "\\" insted of just "\". KeyFilePath Takes the path where you have to keep the key for the encrypted file, Path Takes the path of the file which has to be encrypted
Note: You Can Use The Key File To Store Multiple Keys But The Keys Must Not Be of The Same File Else You Will Get A Wrong Key Error'''
file1 = open(Path,'r')
data = (file1.read()).encode()
with open(Path,'w') as file:
e_file = Encrypt(bytes(data))
key = str(e_file[1])
e_data = str(e_file[3])
file.write(e_data)
if KeyFilePath is not None:
with open(KeyFilePath,'a') as keyf:
keyf.write(Path+':'+';'+':'+';')
keyf.write(key)
keyf.write('\n')
if KeyFilePath is None:
Error.NoKeyFile()
file1.close()
def FileDecryption(Path:str,KeyFilePath:str):
'''Path: The Path Of The Encrypted File
KeyFilePath: Path Of That key File Where The Decryption Key Is Stored For The File '''
import ast
file1 = open(Path,'r')
if KeyFilePath is not None:
with open(KeyFilePath,'r') as keyf:
e_data = ast.literal_eval(file1.read())
alls = keyf.read()
splited =alls.split('\n')
for char,i in enumerate(splited):
a = i.split(':;:;')
if a[char] == Path:
key = ast.literal_eval(a[char+1])
break
n_data = str(Decrypt(key,e_data).decode())
file2 = open(Path,'w')
file2.write(n_data)

if KeyFilePath is None:
Error.NoKeyFile()
6 changes: 6 additions & 0 deletions enrocrypt/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ def ModifiedError():
raise ValueError('The List Provided To The Function Is Modified')
def ListIndexError():
raise IndexError('Returned List Must Only Have 4 Elements')
def NoKeyFile():
raise ValueError('No Path For The Key File was Provided')
def WrongKey():
from cryptography.fernet import InvalidToken
raise InvalidToken('The Key Provided Is Not Correct')

0 comments on commit 34bf2de

Please sign in to comment.