Improve the code to get key hash

This commit is contained in:
Alexandre de Souza 2025-06-23 17:26:21 -03:00
parent 4a79a5e6e1
commit 981daa06b3
No known key found for this signature in database
GPG key ID: E39228FFBA346545

View file

@ -37,8 +37,13 @@ defmodule Livebook.Teams.Org do
@doc """
Generates a hash key.
"""
@spec key_hash(%{teams_key: String.t()}) :: String.t()
@spec key_hash(%{teams_key: String.t()} | String.t()) :: String.t()
def key_hash(%{teams_key: teams_key}) do
key_hash(teams_key)
end
def key_hash(teams_key) do
hash = :crypto.hash(:sha256, teams_key)
Base.url_encode64(hash, padding: false)
end