-
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.
- Loading branch information
0 parents
commit 0d85592
Showing
9 changed files
with
166 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2021 Morgan-Phoenix | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,28 @@ | ||
# EnroCrypt | ||
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``` | ||
## Manual Installation | ||
If For Some Reason You Can't Install EnroCrypt From PyPi You Can Download It Manually Too: | ||
* Clone This Repo | ||
* Cut-Paste This Repo In Your Python Scripts Path | ||
* Enter In The Folder Where You See "setup.py" file | ||
* shift+right click in the Folder And Click On "Open Powershell window Here" | ||
* Type `python setup.py install`<br> | ||
After Following All The Steps Mentioned Above (If You Don't Get An Error) EnroCrypt Is Installed, Now You Can Import It Right Away | ||
## Features | ||
* Strong Encryption | ||
* Strong Salted Hashing | ||
* Some Basic Functions | ||
## Usage | ||
```python | ||
# For Encryption | ||
import enrocrypt | ||
value = enrocrypt.encryption.Encrypt(b'text') | ||
print(value) | ||
# For Decryption | ||
original_value = enrocrypt.encryption.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 |
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,2 @@ | ||
__author__ = 'Morgan-Phoenix' | ||
__cached__ = 'cache' |
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,5 @@ | ||
def seperator(Data:str): | ||
'''Takes A String And Returns A List. List Will Have The Seperated Value of The String Provided ''' | ||
a = str(Data) | ||
final = list(a) | ||
return final |
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,57 @@ | ||
from .error import Error | ||
def _Keyencryption(key:bytes): | ||
import base64 | ||
bases = base64.standard_b64encode(key) | ||
baseu = base64.urlsafe_b64encode(bases) | ||
return baseu | ||
def _Keydecryption(key:bytes): | ||
import base64 | ||
bases = base64.standard_b64decode(key) | ||
baseu = base64.urlsafe_b64decode(bases) | ||
return baseu | ||
def _dataencryption(data:bytes): | ||
import base64 | ||
bases = base64.standard_b64encode(data) | ||
baseu = base64.urlsafe_b64encode(bases) | ||
return baseu | ||
def _datadecryption(data:bytes): | ||
import base64 | ||
baseu = base64.urlsafe_b64decode(data) | ||
bases = base64.standard_b64decode(baseu) | ||
return bases | ||
def _BaseEncryption(text:bytes): | ||
from cryptography.fernet import Fernet | ||
key = Fernet.generate_key() | ||
f = Fernet(key) | ||
e = f.encrypt(text) | ||
return [key,e] | ||
def _BaseDecryption(key:bytes,text:bytes): | ||
from cryptography.fernet import Fernet | ||
f = Fernet(key) | ||
e = f.decrypt(text) | ||
return e | ||
|
||
def Encrypt(Data:bytes): | ||
basee = _BaseEncryption(Data) | ||
e_data = _dataencryption(basee[1]) | ||
e_key = _Keyencryption(basee[0]) | ||
final = [] | ||
final.append('Key →');final.append(e_key);final.append('Encrypted Data →');final.append(e_data) | ||
return final | ||
def Decrypt(Key:bytes,Encrypted_Data:bytes): | ||
d_key = _Keydecryption(Key) | ||
d_data = _datadecryption(Encrypted_Data) | ||
based = _BaseDecryption(d_key,d_data) | ||
return based | ||
def Decrypt_List(Data:list): | ||
'''Takes The List Returned By Encrypt Function "AS IS" Without Modification''' | ||
if 'Key →' and 'Encrypted Data →' not in Data: | ||
Error.ModifiedError() | ||
if len(Data) != 4: | ||
Error.ListIndexError() | ||
Key = Data[1] | ||
e_Data = Data[3] | ||
d_key = _Keydecryption(Key) | ||
d_data = _datadecryption(e_Data) | ||
based = _BaseDecryption(d_key,d_data) | ||
return based |
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,5 @@ | ||
class Error(): | ||
def ModifiedError(): | ||
raise ValueError('The List Provided To The Function Is Modified') | ||
def ListIndexError(): | ||
raise IndexError('Returned List Must Only Have 4 Elements') |
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,20 @@ | ||
def Hash(Data:str): | ||
'''Inreversable Hash Function Don't Use If U Want To Get The Content Back''' | ||
import hashlib, base64 | ||
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] | ||
# salting | ||
salt = ['H', 'c', 'D', 'L', 'b', 'M', 'S', 'a', 'N', 'q', 'K', 'j', 'V', 'd', 'O', 'W', 'x'] | ||
c = (b[0].split("G"or"g"or"v"or"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)) | ||
return(e[0]) |
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,6 @@ | ||
[build-system] | ||
requires = [ | ||
"setuptools>=42", | ||
"wheel" | ||
] | ||
build-backend = "setuptools.build_meta" |
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,22 @@ | ||
from setuptools import setup,find_packages | ||
file = open('README.md','r').read() | ||
setup( | ||
name="enrocrypt", | ||
version="1.0.0", | ||
author="Morgan-Phoenix", | ||
author_email="[email protected]", | ||
description="This is a Python Module For Encryption, Hashing And Other stuff", | ||
long_description=file, | ||
long_description_content_type="text/markdown", | ||
url="https://github.com/Morgan-Phoenix/EnroCrypt", | ||
project_urls={ | ||
"Bug Tracker": "https://github.com/Morgan-Phoenix/EnroCrypt/issues", | ||
}, | ||
classifiers=[ | ||
"Programming Language :: Python :: 3", | ||
"License :: OSI Approved :: MIT License", | ||
"Operating System :: OS Independent", | ||
], | ||
packages=find_packages(), | ||
python_requires=">=3.8", | ||
) |