Convert python script to microflow

0
Hello everyone, I want to convert this code part from python, into a microflow.   cipher = AES.new(bytes.fromhex(key_hex), AES.MODE_CBC, iv.encode()) ciphertext = cipher.encrypt(pad(request_param_json.encode("utf-8"), AES.block_size))   How to do it with microflow?
asked
1 answers
2

Hi Fadil,

Three ways come to my mind:

1-Use Encryption module https://marketplace.mendix.com/link/component/1011 and read this https://docs.mendix.com/appstore/modules/encryption/

2- Create a custom Java action which does the same 

import javax.crypto.Cipher;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;

public class EncryptionHelper {

    public static String encrypt(String plainText, String key, String iv) throws Exception {
        Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
        SecretKeySpec secretKeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");
        IvParameterSpec ivParameterSpec = new IvParameterSpec(iv.getBytes("UTF-8"));

        cipher.init(Cipher.ENCRYPT_MODE, secretKeySpec, ivParameterSpec);

        byte[] encrypted = cipher.doFinal(plainText.getBytes("UTF-8"));
        return new String(Base64.getEncoder().encode(encrypted));
    }
}

3- If you know any external service can do this thing you might use REST Service to achieve that

 

Regards

answered