Hey I need to encrypt a message in python but I have a javascript example.
This is what I have.
BLOCK_SIZE=16
message = 1234
passphrase = "ed8b1a3b-5cf1-4ba5-87af-790905f6bae3"
def encrypt(message, passphrase):
# passphrase MUST be 16, 24 or 32 bytes long, how can I do that ?
IV = Random.new().read(BLOCK_SIZE)
aes = AES.new(passphrase, AES.MODE_ECB, IV)
return base64.b64encode(aes.encrypt(message))
print (encrypt(message , passphrase))
and here is the example
import * as CryptoJS from 'crypto-js';
aesEncrypt(text, key){
let k = key.replace(/-/g, '').substring(0,16);
k = CryptoJS.enc.Utf8.parse(k);
const iv = CryptoJS.enc.Utf8.parse('0000000000000000');
const encrypted = CryptoJS.AES.encrypt(text.trim(), k, {
keySize: 16,
iv: iv,
mode: CryptoJS.mode.ECB,
padding: CryptoJS.pad.Pkcs7
});
console.log(encrypted.toString());
return encrypted.toString();
}