pip install pycrypto
# -*- coding: utf-8 -*-
'''
Created on Mon Mar 12 16:33:10 2018
@author: lnanda
Script to generate a random text which can be passed to properties file as a basic security mech
NS02HJxCa2rH5sbJEVw7UVZcOIv89eHFM7hIFgYDTD8=
NOTE: Key must be 16 digits long
Sample call:
C:\\Users\\lnanda\\Desktop\\Lokesh\\inmoment\\inmoment_main\\inmoment_codebase>python encrypt_me.py 1102 8050614890805061
'''
from Crypto.Cipher import AES
import base64
import sys
def encrypt_me(secret_msg, key):
msg_text = secret_msg.rjust(48)
secret_key = key
cipher = AES.new(secret_key,AES.MODE_ECB)
encoded = base64.b64encode(cipher.encrypt(msg_text))
return encoded.strip().decode("utf-8")
if __name__ == '__main__':
secret_msg = sys.argv[1]
key = sys.argv[2]
encoded_value = encrypt_me(secret_msg, key)
print('Please find the encoded value below:')
print(encoded_value)
-------------------------------------------------------------------
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 12 16:33:10 2018
@author: lnanda
Script to generate a random text which can be passed to properties file as a basic security mech
NOTE: Key must be 16 digits long
"""
from Crypto.Cipher import AES
import base64
import sys
def decrypt_me(encoded_msg, key):
secret_key = key
cipher = AES.new(secret_key,AES.MODE_ECB)
decoded = cipher.decrypt(base64.b64decode(encoded_msg))
return decoded.strip().decode("utf-8")
if __name__ == '__main__':
encoded_msg = sys.argv[1]
key = sys.argv[2]
decoded_value = decrypt_me(encoded_msg, key)
print(decoded_value)
# -*- coding: utf-8 -*-
'''
Created on Mon Mar 12 16:33:10 2018
@author: lnanda
Script to generate a random text which can be passed to properties file as a basic security mech
NS02HJxCa2rH5sbJEVw7UVZcOIv89eHFM7hIFgYDTD8=
NOTE: Key must be 16 digits long
Sample call:
C:\\Users\\lnanda\\Desktop\\Lokesh\\inmoment\\inmoment_main\\inmoment_codebase>python encrypt_me.py 1102 8050614890805061
'''
from Crypto.Cipher import AES
import base64
import sys
def encrypt_me(secret_msg, key):
msg_text = secret_msg.rjust(48)
secret_key = key
cipher = AES.new(secret_key,AES.MODE_ECB)
encoded = base64.b64encode(cipher.encrypt(msg_text))
return encoded.strip().decode("utf-8")
if __name__ == '__main__':
secret_msg = sys.argv[1]
key = sys.argv[2]
encoded_value = encrypt_me(secret_msg, key)
print('Please find the encoded value below:')
print(encoded_value)
-------------------------------------------------------------------
# -*- coding: utf-8 -*-
"""
Created on Mon Mar 12 16:33:10 2018
@author: lnanda
Script to generate a random text which can be passed to properties file as a basic security mech
NOTE: Key must be 16 digits long
"""
from Crypto.Cipher import AES
import base64
import sys
def decrypt_me(encoded_msg, key):
secret_key = key
cipher = AES.new(secret_key,AES.MODE_ECB)
decoded = cipher.decrypt(base64.b64decode(encoded_msg))
return decoded.strip().decode("utf-8")
if __name__ == '__main__':
encoded_msg = sys.argv[1]
key = sys.argv[2]
decoded_value = decrypt_me(encoded_msg, key)
print(decoded_value)