Hi folks,
I’m attempting to port this JS code into its Erlang/Elixir equivalent:
const key = "mysecretkey";
function decryptString(encryptedString) {
const algorithm = 'aes256';
const decipher = crypto.createDecipher(algorithm, key);
return decipher.update(encryptedString, 'hex', 'utf8') +
decipher.final('utf8');
}
This is as far as I have gotten so far in E land:
iex> key = "mysecretkey"
iex> encrypted_text = "myencryptedtext-changed-for-this-example"
iex> :crypto.crypto_one_time(:aes_256_ecb, key, encrypted_text, encrypt: false)
** (ErlangError) Erlang error: {:badarg, {'api_ng.c', 143}, 'Bad key size'}
(crypto 4.8.3) :crypto.ng_crypto_one_time_nif(:aes_256_ecb, "mysecretkey", "", "myencryptedtext-changed-for-this-example", false, :undefined)
Clearly the precise example I’ve given will never work since I’ve redacted both the key and encrypted text. However the error message I’ve included above is the real thing.
Does anyone know what I’m missing?


















