fnux
Hello !
I was expecting :crypto.block_encrypt :aes_ige256 to be symmetric, I don’t get what’s wrong. Can someone enlighten me ?
Here is an example script :
data = <<666::size(256)-unit(8)>>
tmp_aes_key = <<1234567890::size(32)-unit(8)>>
tmp_aes_iv = <<0987654321::size(32)-unit(8)>>
encrypted = :crypto.block_encrypt :aes_ige256, tmp_aes_key, tmp_aes_iv, data
decrypted = :crypto.block_decrypt :aes_ige256, tmp_aes_key, tmp_aes_iv, data
IO.puts "-- Initial Data --"
IO.inspect data
IO.puts "-- Encrypted --"
IO.inspect encrypted
IO.puts "-- Decrypted --"
IO.inspect decrypted
And its output :
-- Initial Data --
<<0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, ...>>
-- Encrypted --
<<13, 146, 170, 197, 88, 244, 100, 48, 180, 234, 28, 168, 36, 10, 88, 225, 15,
232, 33, 201, 90, 37, 54, 105, 155, 70, 166, 40, 128, 12, 107, 11, 234, 61,
80, 202, 89, 18, 222, 125, 127, 133, 98, 236, 28, 107, 254, 155, 130, 223,
...>>
-- Decrypted --
<<200, 243, 4, 223, 10, 44, 240, 101, 171, 77, 103, 159, 39, 239, 138, 91, 108,
248, 162, 162, 228, 170, 138, 113, 98, 56, 248, 183, 167, 19, 123, 243, 162,
144, 214, 253, 136, 98, 37, 210, 14, 108, 56, 31, 33, 222, 148, 228, 183, 8,
...>>
Thanks !
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
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
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
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
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #blog-post
- #ai
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
OvermindDL1
Shouldn’t
datahere beencrypted?fnux
Ow, my bad. tired
OvermindDL1
Hehe, happens to us all. ^.^
Also you can click the checkmark on a post to mark that post as the one that resolves the issue.
slouchpie
For posterity: don’t use
:crypto.block_encryptfor anything new you are writing.Instead, use
:crypto:crypto_one_time.See here for info: New and Old API — OTP 29.0.2 (crypto 5.9)
ijunaidfarooq
Hi, I had these 2 methods
I am trying make them work with
:crypto:crypto_one_time/4, 5When I do this
it says:
# Erlang error: {:badarg, {'api_ng.c', 141}, 'Unknown cipher'}any clue?
voltone
The new API only accepts the algorithm atom values listed in the latest
:cryptomodule docs. So:aes_cbc256should be:aes_256_cbc.ijunaidfarooq
but how a same module can do encrypt and decrypt both?
just the last flag for true and false will decide ? its ecrypt or decrypt ?
voltone
Yes, the last argument is actually an option list, so you could do:
Passing
trueorfalseinstead is just a shortcut.ijunaidfarooq
thank you.
al2o3cr
IMPORTANT: unless this code is called with a different value in
SNAP_IVevery time, there is a potential security hole when reusing an IV with CBC: