Class: Synthra::Types::TextContent::Sha1

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

Overview

Sha1 type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



85
86
87
# File 'lib/synthra/types/text_content/security.rb', line 85

def generate_edge(rng, context, args)
  ["0000000000000000000000000000000000000000", "ffffffffffffffffffffffffffffffffffffffff"].sample(random: rng.instance_variable_get(:@random))
end

#generate_invalid(rng, context, args) ⇒ Object



89
90
91
# File 'lib/synthra/types/text_content/security.rb', line 89

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



79
80
81
82
83
# File 'lib/synthra/types/text_content/security.rb', line 79

def generate_random(rng, context, args)
  # Generate 40-character hex SHA1 hash
  chars = ('0'..'9').to_a + ('a'..'f').to_a
  40.times.map { rng.sample(chars) }.join
end