Class: Synthra::Types::TextContent::Encrypt

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

Overview

Encrypt type

Instance Method Summary collapse

Instance Method Details

#generate_edge(rng, context, args) ⇒ Object



120
121
122
# File 'lib/synthra/types/text_content/security.rb', line 120

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

#generate_invalid(rng, context, args) ⇒ Object



124
125
126
# File 'lib/synthra/types/text_content/security.rb', line 124

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

#generate_random(rng, context, args) ⇒ Object



113
114
115
116
117
118
# File 'lib/synthra/types/text_content/security.rb', line 113

def generate_random(rng, context, args)
  # Generate a base64-like encrypted string
  chars = ('A'..'Z').to_a + ('a'..'z').to_a + ('0'..'9').to_a + ['+', '/', '=']
  length = rng.int(20, 40)
  length.times.map { rng.sample(chars) }.join
end