Thanks a Lot @NobbZ - Solution worked as expected.
The updated code snippet I used -
def encrypt(plaintext) do
# create random Initialisation Vector
iv = :crypto.strong_rand_bytes(16)
# sample secret_key is a 32 bit hex string
secret_key = Base.decode16!("548F11DE7F4393EAC0BB2391797AF7B5")
plaintext = pad(plaintext, @block_size)
encrypted_text = :crypto.crypto_one_time(:aes_128_cbc, secret_key, iv, plaintext, true )
encrypted_text = ( iv <> encrypted_text )
:base64.encode(encrypted_text)
end
before base64’ing I concatenated with IV.
Thanks,
Niranjan


















