Module: Baseh::Profiles

Defined in:
lib/baseh/profiles.rb

Overview

Frozen tier profiles. Each is built from the full alphanumeric set with cumulative visual and spoken strips; the spoken strips interact with the visual ones exactly as the web tools derive them, so the tool capacities match.

Minimum  36 symbols, no checksum      2,176,782,336 ids
Light    31 symbols, 1 checksum         887,503,681 ids
Medium   28 symbols, 1 checksum         481,890,304 ids (default)
Heavy    26 symbols, 1 checksum         308,915,776 ids

All four keep the typed O/I/L aliases where possible and run the default profanity blocklist. Minimum also uses a hyphen delimiter; the rest have none. The _p variants are identical but with feistel-v1 permutation and require caller-supplied key material.

Constant Summary collapse

OIL_ALIASES =
{ "O" => "0", "I" => "1", "L" => "1" }.freeze
TIERS =

Tier shapes shared by the plain and (-p) keyed helpers. The values are thawed on every build, so each helper returns a fresh mutable profile.

{
  minimum: {
    profile_id: "baseh-minimum",
    body_alphabet: "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ",
    checksum_alphabet: "",
    checksum_length: 0,
    separator: "-",
    grouping: [3, 3],
    aliases: {}
  },
  light: {
    profile_id: "baseh-light",
    body_alphabet: "0123456789ABCEFGHJKMNPQRSUVWXYZ",
    checksum_alphabet: "234679ACEFGHJKMNPQRUVWXY",
    checksum_length: 1,
    separator: "",
    grouping: [],
    aliases: { **OIL_ALIASES, "D" => "B", "T" => "P" }
  },
  medium: {
    profile_id: "baseh-medium",
    body_alphabet: "0123456789ACDEFGHJKMPQRUVXYZ",
    checksum_alphabet: "234679ACDEFGHJKMPQRUVXY",
    checksum_length: 1,
    separator: "",
    grouping: [],
    # B and S are dropped for looking like 8 and 5; since they can never
    # be issued, a typed B is always an 8 and a typed S always a 5.
    aliases: { **OIL_ALIASES, "B" => "8", "S" => "5", "T" => "P",
               "N" => "M", "W" => "V" }
  },
  heavy: {
    profile_id: "baseh-heavy",
    body_alphabet: "0123456789ABCEFHJKMPQRVXYZ",
    checksum_alphabet: "234679ACEFHJKMPQRUVXY",
    checksum_length: 1,
    separator: "",
    grouping: [],
    aliases: { **OIL_ALIASES, "D" => "B", "T" => "P", "N" => "M",
               "W" => "V", "S" => "F", "G" => "C" }
  }
}.freeze

Class Method Summary collapse

Class Method Details

.baseh_heavy_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-heavy with feistel-v1 permutation. key_bytes is required.



104
105
106
# File 'lib/baseh/profiles.rb', line 104

def baseh_heavy_p_v1(key_bytes:, key_id: "default", rounds: 8)
  tier(:heavy, keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_heavy_v1Object

Conservative alphabet plus spoken heavy, one checksum symbol.



99
100
101
# File 'lib/baseh/profiles.rb', line 99

def baseh_heavy_v1
  tier(:heavy, { enabled: false }, false)
end

.baseh_light_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-light with feistel-v1 permutation. key_bytes is required.



84
85
86
# File 'lib/baseh/profiles.rb', line 84

def baseh_light_p_v1(key_bytes:, key_id: "default", rounds: 8)
  tier(:light, keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_light_v1Object

Visual light plus spoken light, one checksum symbol.



79
80
81
# File 'lib/baseh/profiles.rb', line 79

def baseh_light_v1
  tier(:light, { enabled: false }, false)
end

.baseh_medium_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-medium with feistel-v1 permutation. key_bytes is required.



94
95
96
# File 'lib/baseh/profiles.rb', line 94

def baseh_medium_p_v1(key_bytes:, key_id: "default", rounds: 8)
  tier(:medium, keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_medium_v1Object

Visual medium plus spoken medium, one checksum symbol. The default.



89
90
91
# File 'lib/baseh/profiles.rb', line 89

def baseh_medium_v1
  tier(:medium, { enabled: false }, false)
end

.baseh_minimum_p_v1(key_bytes:, key_id: "default", rounds: 8) ⇒ Object

baseh-minimum with feistel-v1 permutation. key_bytes is required.



74
75
76
# File 'lib/baseh/profiles.rb', line 74

def baseh_minimum_p_v1(key_bytes:, key_id: "default", rounds: 8)
  tier(:minimum, keyed_permutation(key_bytes, key_id, rounds), true)
end

.baseh_minimum_v1Object

Alphanumeric, no safety strips, no checksum, hyphen-delimited XXX-XXX.



69
70
71
# File 'lib/baseh/profiles.rb', line 69

def baseh_minimum_v1
  tier(:minimum, { enabled: false }, false)
end