Class: Synthra::Types::TextContent::PasswordHash

Inherits:
Base
  • Object
show all
Defined in:
lib/synthra/types/text_content/security.rb

Overview

PasswordHash type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



51
52
53
# File 'lib/synthra/types/text_content/security.rb', line 51

def generate_edge(rng, context, args)
  ["$2a$10$00000000000000000000000000000000000000000000000000000000"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



55
56
57
# File 'lib/synthra/types/text_content/security.rb', line 55

def generate_invalid(rng, context, args)
  [nil, "not a hash", "invalid", [], {}].sample(random: rng.instance_variable_get(:@random))
end

#generate_random(rng, context, args) ⇒ Object



45
46
47
48
49
# File 'lib/synthra/types/text_content/security.rb', line 45

def generate_random(rng, context, args)
  # Generate bcrypt-like hash (60 characters)
  chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + ['./']
  "$2a$10$#{54.times.map { rng.sample(chars) }.join}"
end