Packard_Goose

Packard_Goose

How would I go about attempting to encrypt a file in elixir? I need to store some sensitive information in a text file such as a .dat but the information can only be decrypted if you have the passphrase to unlock the contents of the file. I’ve tried looking at :crypto but I don’t really understand it.

This answer seems to be what I’m looking for but I don’t know if it really does what I want it to. I would simply use Base.decode64(:crypto.block_decrypt(:aes_ecb, key, input)) to decrypt the data?

Showing Posts 1 to 6

hubertlepicki

hubertlepicki

I would go with GnuPG (Gnu Privacy Guard, https://www.gnupg.org/), possibly calling it directly from the command line, or use some wrapper. Googling found this GitHub - rozap/exgpg: gpg interface · GitHub which does not look maintained but it may work, or give you idea how to call the tool.

I use GnuPG for stuff like encrypting backup files from shell scripts and it is outstanding.

hauleth

hauleth

If you do not understand crypto module, then don’t implement encrypting files on your own, because it is almost 100% sure that you will do something wrong (like using ECB mode, which you did in your example). Do as @hubertlepicki said and use external tools that do this for longer, they do it better, and have broader knowledge of cryptography (and even despite that they sometimes do something in the wrong way).

voltone

voltone

I should have an Elixir native, dependency free implementation of the AESCrypt file format somewhere. Not exactly the pinnacle of proven, peer reviewed standards, but better than most roll-your-own attempts. Your weakest link even with the strongest algorithms is going to be keeping the pass phrase secure.

I’ll check tomorrow if my code is in any shape to be published…

voltone

voltone

Found the code, cleaned it up a bit and published a v0.1.0:

There is room for improvements, but it successfully decrypts files created by the Linux CLI version of eascrypt, and vice versa.

Packard_Goose

Packard_Goose OP

Wow this is exactly what I was looking for! Thanks for the quick reply.

voltone

voltone

Please beware that AES Crypt is not quite a substitute for a tool like GPG. Don’t use it for highly sensitive data, just for ‘casual protection’.

It does implement key wrapping, unlike other file encryption packages I saw on Hex, but the KDF is proprietary and relatively weak by today’s standards, possibly enabling brute force attacks on modern hardware. Make sure you use strong passwords to limit that risk.

I could add support for PBKDF2, but that would break interoperability with other tools.

— All posts loaded —

Where Next? Top

Trending in Questions Top

stjefim
Hello! Suppose you are building workflow (order / task / payment) processing system with the following requirements: Each workflow con...
New
Blokh
Hey guys, I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly Do you guys have any suggestions what is the best prac...
New
kszambelanczyk
Hello! Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app. I creat...
New
Onor.io
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
jaybe78
Hello, I’m developing a online persistent chat system (what’s app) like using elixir/dynamodb/aws for a mobile app(flutter). The diffic...
New
Trolleger
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
widianto
I think I’ve found a small improvement I could contribute to <%= web_namespace %>.CoreComponents (installer/templates/phx_web/compo...
New

Other Trending Topics Top

garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
mcass19
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Damirados
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve. They are GUI (Emerge) and State management (S...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
wintermeyer
There are three potential reasons for members of this forum to have a look at https://vutuv.de You are tired or annoyed of LinkedIn. Yo...
New
webofbits
Aludel - LLM Evaluation Workbench Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews