       "Hello"
   """
   def decrypt(<<key_tag::binary-1, iv::binary-16, ciphertext::binary>> = _ciphertext) do
-    key   = get_key(key_tag)
-    state = :crypto.stream_init(:aes_ctr, key.key, iv)
+    key_config = get_key_config(key_tag)
+    state      = :crypto.stream_init(:aes_ctr, get_key_value(key_config), iv)
 
     {_state, plaintext} = :crypto.stream_decrypt(state, ciphertext)
     plaintext

      true
  """
  def encrypt(plaintext, key_tag \\ @tag) do
    key   = get_key(key_tag)
    iv    = :crypto.strong_rand_bytes(16)
    state = :crypto.stream_init(:aes_ctr, key.key, iv)

    {_state, ciphertext} = :crypto.stream_encrypt(state, to_string(plaintext))
    key.tag <> iv <> ciphertext
  end

  @doc """

    @key.tag
  end

  defp get_key_config(tag) do
    Enum.find(@keys, fn(key) -> key.tag == tag end)
  end

  defp get_key_value(key_config) do
    case key_config do
      {:system, env_var} ->
        System.get_env(env_var)
      
      _ ->
        key_config.key
    end
  end
end
