Class: Synthra::Types::TextContent::Sha256

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

Overview

Sha256 type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



102
103
104
# File 'lib/synthra/types/text_content/security.rb', line 102

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

#generate_invalid(rng, context, args) ⇒ Object



106
107
108
# File 'lib/synthra/types/text_content/security.rb', line 106

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



96
97
98
99
100
# File 'lib/synthra/types/text_content/security.rb', line 96

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