Porting node.js encryption function to Elixir

AES256 require key to be exactly 32 byte long, your key is 11 bytes, 21 bytes too short. JS code probably does some padding to achieve what you want.

However:

For gods sake, do not use this code. Burry it in the dessert, and wear gloves. After that burn all your clothes.

Jokes aside - this is terrible way to do cryptography and encrypt data. Just don’t do it that way. If you have “AES” written in your code, then you are probably vulnerable. It is even hard to list what is wrong there:

  • low entropy keys - just use KDF for dear gods
  • no padding for data
  • no authentication of data
  • using ECB mode for encryption

This is nowhere to be even considered to be a remotely reasonable implementation. It is just insecure.