View Source EctoEncryptedId.ExampleField.Id (EctoEncryptedId v0.1.0)

Container type for the encrypted field. Implements struct storing the id and related functions.

Summary

Functions

Create id struct from an encrypted value.

Create id struct from an encrypted value.

Create id struct from a plain integer value.

Types

@type t() :: %EctoEncryptedId.ExampleField.Id{encrypted: String.t(), plain: integer()}

Functions

Link to this function

from_encrypted(id, opts \\ [])

View Source
@spec from_encrypted(id :: String.t(), opts :: keyword()) :: {:ok, t()} | :error

Create id struct from an encrypted value.

Supported options:

  • :secret_key_fn - custom function to fetch secret key

Returns {:ok, %Id{}} on success or :error on failure

Link to this function

from_encrypted!(id, opts \\ [])

View Source
@spec from_encrypted!(id :: String.t(), opts :: keyword()) :: t()

Create id struct from an encrypted value.

Supported options:

  • :secret_key_fn - custom function to fetch secret key

Returns %Id{} on success. Raises EctoEncryptedId.DecryptionError on failure.

Link to this function

from_plain(id, opts \\ [])

View Source
@spec from_plain(id :: integer(), opts :: keyword()) :: t()

Create id struct from a plain integer value.

Supported options:

  • :secret_key_fn - custom function to fetch secret key

Returns %Id{}.