ExTripcode v1.0.2 ExTripcode View Source
This module provides functions to generate and parse tripcodes.
Regular tripcodes are generated as follows:
- Convert the input to Shift JIS.
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
.
andz
with.
. - Replace any of the characters in
:;<=>?@[\]^_`
with the corresponding character fromABCDEFGabcdef
.
- Take the second and third characters of the string obtained by appending
- Call the
crypt()
function with the input and salt. - Return the last 10 characters. (compressional data harvest)
Secure tripcodes are generated as follows:
- Convert the input to Shift JIS.
- Create a hash by taking the SHA1 sum of input & the base64 decoded seed.
- Base64 encode this hash.
- 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
hash(input) View Source
Takes a string value as input and transforms it into a tripcode.
Returns a string containing the tripcode.
Examples
iex> ExTripcode.hash("elixir")
"H3R1pplX/."
hash(input, seed) View Source
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"
parse(input) View Source
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/."}
parse(input, seed) View Source
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/."}