ExkPasswd.Transform.Substitution
(ExkPasswd v0.1.1)
View Source
Character substitution transformation (leetspeak-style).
This transform replaces characters with symbols or numbers:
a→@e→3i→!o→0s→$
Modes
:none- No substitutions:always- Always apply substitutions (deterministic, no entropy):random- Randomly apply per word (adds 1 bit entropy per word)
Examples
subs = %{"e" => "3", "o" => "0"}
transform = %ExkPasswd.Transform.Substitution{map: subs, mode: :always}
ExkPasswd.Transform.apply(transform, "hello", config)
#=> "h3ll0"
transform = %ExkPasswd.Transform.Substitution{map: subs, mode: :random}
ExkPasswd.Transform.apply(transform, "hello", config)
#=> "h3ll0" or "hello" (random)
Summary
Functions
Calculate how many substitutable characters exist in a word.
Returns the default character substitution map.
Types
Functions
@spec count_substitutable(String.t(), map()) :: non_neg_integer()
Calculate how many substitutable characters exist in a word.
Useful for entropy calculations and analysis.
Parameters
word- The word to analyzesubstitutions- Map of character substitutions
Returns
Count of substitutable characters.
Examples
iex> ExkPasswd.Transform.Substitution.count_substitutable("hello", %{
...> "e" => "3",
...> "l" => "1",
...> "o" => "0"
...> })
4
@spec default_substitutions() :: map()
Returns the default character substitution map.
Examples
iex> subs = ExkPasswd.Transform.Substitution.default_substitutions()
...> Map.get(subs, "e")
"3"