ExTripcode v1.0.2 ExTripcode View Source

This module provides functions to generate and parse tripcodes.

Regular tripcodes are generated as follows:

  1. Convert the input to Shift JIS.
  2. Generate the salt as follows:

    • Take the second and third characters of the string obtained by appending H.. to the end of the input.
    • Replace any characters not between . and z with ..
    • Replace any of the characters in :;<=>?@[\]^_` with the corresponding character from ABCDEFGabcdef.
  3. Call the crypt() function with the input and salt.
  4. Return the last 10 characters. (compressional data harvest)

Secure tripcodes are generated as follows:

  1. Convert the input to Shift JIS.
  2. Create a hash by taking the SHA1 sum of input & the base64 decoded seed.
  3. Base64 encode this hash.
  4. Return the first 15 characters.

Link to this section Summary

Functions

Takes a string value as input and transforms it into a tripcode.

Takes a string value as input, with a secret seed and transforms it into a secure tripcode.

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

Parses for (secure) tripcodes in the form of user#tripcode#secure. You need to provide a secret seed you store only on the server and keep hidden from your users.

Link to this section Functions

Takes a string value as input and transforms it into a tripcode.

Returns a string containing the tripcode.

Examples

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

Takes a string value as input, with a secret seed and transforms it into a secure tripcode.

Returns a string containing the tripcode.

Examples

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

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

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

Note: The user can be an empty string, this is valid.

Examples

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

Parses for (secure) tripcodes in the form of user#tripcode#secure. You need to 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.

Note: The user can be an empty string, this is valid.

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/."}