-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Registration module ADDED Manual Encryptor ADDED(for Debug)
- Loading branch information
1 parent
829ec01
commit 908df69
Showing
2 changed files
with
33 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,32 @@ | ||
from Crypto.Cipher import AES | ||
import hashlib | ||
import base64 | ||
BLOCK_SIZE = 32 | ||
""" | ||
Use this file to encrypt a password manually | ||
""" | ||
def decrypt(ciphertext, mode=AES.MODE_ECB): | ||
key = "ueVbH0RGVHfLBo81/3BqHQ==" | ||
key = base64.b64decode(key) | ||
ciphertext = ciphertext.decode("hex") | ||
encryptor = AES.new(key,mode) | ||
plaintext = encryptor.decrypt(ciphertext) | ||
plaintext = pkcs5_unpad(plaintext) | ||
h = hashlib.new('sha1') | ||
h.update(plaintext) | ||
return h.hexdigest() | ||
|
||
def encrypt(plaintext, mode=AES.MODE_ECB): | ||
key = "ueVbH0RGVHfLBo81/3BqHQ==" | ||
key = base64.b64decode(key) | ||
cipher = AES.new(key, mode) | ||
crypted = cipher.encrypt(pkcs5_pad(plaintext)) | ||
crypted = crypted.encode("hex") | ||
return crypted | ||
|
||
def pkcs5_unpad(s): | ||
return s[0:-ord(s[-1])] | ||
def pkcs5_pad(s): | ||
return s + (BLOCK_SIZE - len(s) % BLOCK_SIZE) * chr(BLOCK_SIZE - len(s) % BLOCK_SIZE) | ||
|
||
print(encrypt(raw_input("Enter plaintext: "))) |
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