Skip to content

Commit

Permalink
Third-party usage modules added.
Browse files Browse the repository at this point in the history
Registration module ADDED
Manual Encryptor ADDED(for Debug)
  • Loading branch information
NilanjanDaw committed May 15, 2017
1 parent 829ec01 commit 908df69
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Encryption.py
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: ")))
1 change: 1 addition & 0 deletions register.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def takeInput():
password = encrypt(password)
payload = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"personnel_id\"\r\n\r\n" + personnel_id + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"adhaar_number\"\r\n\r\n" + str(adhaar_number) + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"first_name\"\r\n\r\n" + first_name + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"last_name\"\r\n\r\n " + last_name + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"contact_number\"\r\n\r\n" + contact_number +"\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"car_number\"\r\n\r\n" + car_number + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"responder_type\"\r\n\r\n" + responder_type + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"base_station\"\r\n\r\n" + base_station + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW\r\nContent-Disposition: form-data; name=\"password\"\r\n\r\n" + password + "\r\n------WebKitFormBoundary7MA4YWxkTrZu0gW--"
return payload, headers

payload, headers = takeInput()
print "Registering Personnel...",
try:
Expand Down

0 comments on commit 908df69

Please sign in to comment.