Provides crypto functionality like signing and hashing strings.
Summary
Functions
Hashed the given string using sha256 algorithm and encode it as lowercase hex string.
If you pass a %GcsSignedUrl.Client{} as second argument, this function signs the given string with the given
client's private key.
Functions
Hashed the given string using sha256 algorithm and encode it as lowercase hex string.
Examples
iex> GcsSignedUrl.Crypto.sha256("foo")
"1fad6186e41f577a37f56589..."
@spec sign(String.t(), GcsSignedUrl.Client.t()) :: String.t()
@spec sign(String.t(), GcsSignedUrl.SignBlob.OAuthConfig.t()) :: {:ok, String.t()} | {:error, String.t()}
If you pass a %GcsSignedUrl.Client{} as second argument, this function signs the given string with the given
client's private key.
If you pass a %GcsSignedUrl.SignBlob.OAuthConfig{} as second argument, this function signs the given string using
the signBlob REST API.
(see https://cloud.google.com/iam/docs/reference/credentials/rest/v1/projects.serviceAccounts/signBlob)
Examples
iex> GcsSignedUrl.Crypto.sign("foo", %GcsSignedUrl.Client{private_key: "-----BEGIN RSA PRIVATE KEY-----..."})
"..."
iex> GcsSignedUrl.Crypto.sign("foo", %GcsSignedUrl.SignBlob.OAuthConfig{access_token: "..."})
{:ok, "1fad6186e41f577a37f56589..."}