ExTripcode v1.0.0 ExTripcode View Source

This module provides functions to generate and parse tripcodes.

Link to this section Summary

Functions

Takes a string value as input and transforms it into a tripcode. When specifying a seed, we use this to generate a secure tripcode.

Parses a user and tripcode string, in the form of "user#tripcode".

Link to this section Functions

Takes a string value as input and transforms it into a tripcode. When specifying a seed, we use this to generate a secure tripcode.

Returns a string containing the tripcode.

Examples

iex> ExTripcode.hash("elixir")
"H3R1pplX/."

iex> ExTripcode.hash("elixir", "secret")
"KZ1B7o9AtcJD9XQ"

Parses a user and tripcode string, in the form of "user#tripcode".

To also parse for secure tripcodes in the form of "user#tripcode#secure" you need provide a secret seed you store only on the server and keep hidden from your users.

Returns a map containing key-values for all values that are found.

Examples

iex> ExTripcode.parse("User#elixir#elixir", "secret")
%{user: "User", code: "H3R1pplX/.", secure: "KZ1B7o9AtcJD9XQ"}

iex> ExTripcode.parse("User##elixir", "secret")
%{user: "User", secure: "KZ1B7o9AtcJD9XQ"}

iex> ExTripcode.parse("User#elixir", "secret")
%{user: "User", code: "H3R1pplX/."}

iex> ExTripcode.parse("User#elixir")
%{user: "User", code: "H3R1pplX/."}