I am trying to hide an actual string. So, I am choosing encoding mechanism to encode it. Is there any best Encryption/Decryption Algorithms to deal with it ?
How can I do it in Python? The encoded string should be of length 10 (encoded string should be alphanumeric).
I just tried with some code available in Google. How can I format it to get desired output needed ?
from Crypto.Cipher import AES
import base64
MASTER_KEY="Some-long-base-key-to-use-as-encyrption-key"
def encrypt_val(clear_text):
enc_secret = AES.new(MASTER_KEY[:32])
tag_string = (str(clear_text) +
(AES.block_size -
len(str(clear_text)) % AES.block_size) * "\0")
cipher_text = base64.b64encode(enc_secret.encrypt(tag_string))
print cipher_text
encrypt_val("abcd_10.10.10.10_abcdefghijk")
Output for above : ytZyd3PGRg7POl80qlF8Oi79gwj7U31D/rsC50EDCt4=