CharlesO
Please can you provide or point to replacement code for:
crypto — crypto v5.5 (erlang.org)
from here: Deprecations — Erlang/OTP v27.0.1
It seems several functions have no equivalents.
Functions Deprecated in OTP 27
code:lib_dir/2 (this functionality will be removed in a future release)
crypto:private_decrypt/4 (do not use)
crypto:private_encrypt/4 (use public_key:sign/3 instead)
crypto:public_decrypt/4 (use public_key:verify/4 instead)
crypto:public_encrypt/4 (do not use)
mnesia_registry:create_table/_ (use mnesia:create_table/2 instead)
public_key:decrypt_private/2 (do not use)
public_key:decrypt_private/3 (do not use)
public_key:decrypt_public/2 (use public_key:verify/4 instead)
public_key:decrypt_public/3 (use public_key:verify/5 instead)
public_key:encrypt_private/2 (use public_key:sign/3 instead)
public_key:encrypt_private/3 (use public_key:sign 4 instead)
public_key:encrypt_public/2 (do not use)
public_key:encrypt_public/3 (do not use)
ssl:prf/5 (Use export_key_materials/4 instead. Note that in OTP 28 the 'testing' way of calling this function will no longer be supported.)
I have been trying to redo : raw.githubusercontent.com/WhatsApp/WhatsApp-Flows-Tools/refs/heads/main/examples/endpoint/nodejs/basic/src/encryption.js
For a project but the samples are all coming back with depreciated functions. (Even ChatGPT and Copilot return incorrect code)
here is my effort so far:
defmodule Flows do
defmodule FlowEndpointException do
defexception [:message, :status_code]
@impl true
def exception({status_code, message}) do
%__MODULE__{message: message, status_code: status_code}
end
end
def decrypt_request(body, private_pem, passphrase) do
%{
"encrypted_aes_key" => encrypted_aes_key,
"encrypted_flow_data" => encrypted_flow_data,
"initial_vector" => initial_vector
} = body
private_key = :public_key.pem_entry_decode({:RSAPrivateKey, private_pem, passphrase})
try do
decrypted_aes_key =
encrypted_aes_key
|> Base.decode64!()
|> :crypto.decrypt(:rsa, private_key, [
{:rsa_padding, :rsa_pkcs1_oaep_padding},
{:rsa_oaep_md, :sha256}
])
flow_data_buffer = Base.decode64!(encrypted_flow_data)
initial_vector_buffer = Base.decode64!(initial_vector)
tag_length = 16
{encrypted_flow_data_body, encrypted_flow_data_tag} =
:erlang.split_binary(flow_data_buffer, byte_size(flow_data_buffer) - tag_length)
decrypted_json_string =
:crypto.crypto_one_time_aead(
:aes_128_gcm,
decrypted_aes_key,
initial_vector_buffer,
encrypted_flow_data_body,
"",
encrypted_flow_data_tag,
false
)
{
:ok,
%{
decrypted_body: Jason.decode!(decrypted_json_string),
aes_key_buffer: decrypted_aes_key,
initial_vector_buffer: initial_vector_buffer
}
}
rescue
_ ->
raise FlowEndpointException,
{421, "Failed to decrypt the request. Please verify your private key."}
end
end
def encrypt_response(response, aes_key_buffer, initial_vector_buffer) do
flipped_iv = for <<byte <- initial_vector_buffer>>, do: Bitwise.bnot(byte)
{cipher_text, cipher_tag} =
:crypto.crypto_one_time_aead(
:aes_128_gcm,
aes_key_buffer,
flipped_iv,
Jason.encode!(response),
"",
16,
true
)
Base.encode64(cipher_text <> cipher_tag)
end
end
Trending in Questions
I having some trouble figuring out if I have set myself too strict of standards for my production server. Currently I can handle 75% of r...
New
Hello,
I’m trying to build a basic Phoenix web-app, and I’d like to use Tailwind.
However, when I launch mix phx.server, I get an error...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
I’m working on a small exercise involving update_in/3, and I came up with this solution:
data = %{
name: "Periodic Table",
category:...
New
I’ve got trouble wrapping my head around the order in which functions are called in this snippet (from Phoenix’s authentication):
toke...
New
Is there any way to avoid the Hologram compiler running when using iex? It seems like the front-end code could potentially be disregarded...
New
** (ArgumentError) expected :max_attempts to be a positive integer, got: {:@, [line: 10, column: 19], [{:max_attempts, [line: 10, column:...
New
Other Trending Topics
Edit: 2026 May 15 - This post is archived.
Mob is alive!!
Main docs: mob v0.7.11 — Documentation
A bit of explanation for the slightly c...
New
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
A little off-topic, but I feel like people here have a good head on their shoulders.
I used to be quite good at making software. Was luc...
New
Hey. Is there anyone here who creates agents in their apps? Not talking about using agents, but creating them. I’m finding it pretty diff...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
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
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 3- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
Schultzer
Working with crypto without any fundamental understanding is a recipe for disaster, even expert gets this wrong.
First you’ll need to understand why things have been deprecated, and what would be an alternative, if any.
CharlesO
@Schultzer True, but I have a reference implementation in another language: NodeJS.
Porting it to Elixir was not too hard. but I end up with code that will not work in OPT-27, that’s the issue.
I don’t see a clear guide from Erlang documentation on how to replace depreciated functionality, that’s a problem.
voltone
Those deprecations have been reverted in OTP 27.1.