Convert Elixir functions to PHP -- 2

Job ID: 33836653

Budget: $50 – $70 USD

I need someone who can convert the Elixir encrypt and decrypt functions to PHP

def encrypt(plaintext, key \\ default_secret_key()) do
iv = :crypto.strong_rand_bytes(16)
hashed_key = :crypto.hash(:sha256, key)
{ciphertext, tag} = :crypto.block_encrypt(:aes_gcm, hashed_key, iv, {"AES256GCM", plaintext |> to_string(), 16})
iv <> tag <> ciphertext
end

def decrypt(ciphertext, key \\ default_secret_key()) do
<<iv::binary-16, tag::binary-16, ciphertext::binary>> = ciphertext
hashed_key = :crypto.hash(:sha256, key)
:crypto.block_decrypt(:aes_gcm, hashed_key, iv, {"AES256GCM", ciphertext, tag})
end
Related categories: PHP PostgreSQL Elixir