diff --git a/lib/objects/local_string_encoder.rb b/lib/objects/local_string_encoder.rb index 0f4de546c..862d8bcc8 100644 --- a/lib/objects/local_string_encoder.rb +++ b/lib/objects/local_string_encoder.rb @@ -40,6 +40,7 @@ class StringEncoder def read_arguments # Get command line arguments + Print.local 'Reading args from STDIN' if ARGV.size == 0 begin args_array = [] @@ -115,6 +116,7 @@ class StringEncoder Print.local module_name read_arguments + enforce_utf8(self.strings_to_encode) Print.local_verbose "Encoding '#{encoding_print_string}'" encode_all @@ -129,6 +131,15 @@ class StringEncoder Print.local_verbose "(Displaying 1000/#{length} length output)" end + enforce_utf8(self.outputs) + print_outputs + end + + def enforce_utf8(values) + values.map { |o| o.force_encoding('UTF-8') } + end + + def print_outputs puts has_base64_inputs ? base64_encode_outputs : self.outputs end diff --git a/lib/objects/local_string_generator.rb b/lib/objects/local_string_generator.rb index ad570cfff..f03cdd894 100644 --- a/lib/objects/local_string_generator.rb +++ b/lib/objects/local_string_generator.rb @@ -30,6 +30,7 @@ class StringGenerator def read_arguments # Get command line arguments + Print.local 'Reading args from STDIN' if ARGV.size == 0 begin args_array = [] @@ -112,10 +113,16 @@ class StringGenerator Print.local_verbose "(Displaying 1000/#{length} length output)" end + enforce_utf8(self.outputs) + print_outputs + end + + def enforce_utf8(values) + values.map { |o| o.force_encoding('UTF-8') } + end + + def print_outputs puts has_base64_inputs ? base64_encode_outputs : self.outputs - - # TODO: Wrap data in {} - end def base64_encode_outputs diff --git a/lib/objects/system.rb b/lib/objects/system.rb index 61f254be3..d822c09db 100644 --- a/lib/objects/system.rb +++ b/lib/objects/system.rb @@ -319,8 +319,6 @@ class System end # execute calculation script and format output to an array of Base64 strings Print.verbose "Running: ruby #{selected.local_calc_file} #{args_string[0..200]} ..." - $stdout.sync = true - $stderr.sync = true stdout, stderr, status = Open3.capture3("ruby #{selected.local_calc_file}", :stdin_data => args_string) puts stderr outputs = stdout.chomp diff --git a/modules/encoders/cipher/braille/braille.pp b/modules/encoders/cipher/braille/braille.pp new file mode 100644 index 000000000..e69de29bb diff --git a/modules/encoders/cipher/braille/manifests/.no_puppet b/modules/encoders/cipher/braille/manifests/.no_puppet new file mode 100644 index 000000000..e69de29bb diff --git a/modules/encoders/cipher/braille/secgen_local/local.rb b/modules/encoders/cipher/braille/secgen_local/local.rb new file mode 100644 index 000000000..867766bc2 --- /dev/null +++ b/modules/encoders/cipher/braille/secgen_local/local.rb @@ -0,0 +1,28 @@ +#!/usr/bin/ruby +require_relative '../../../../../lib/objects/local_string_encoder.rb' +require 'braille' +require 'braille/translator' + +class BrailleEncoder < StringEncoder + + def initialize + super + self.module_name = 'Braille Encoder' + self.strings_to_encode = [] + end + + def encode(str) + braille = Braille::Translator.new + translation = [] + str.each_char do |char| + if ! char =~ /[a-zA-Z0-9]/ # If non-alphanumeric, return the character as is. + translation << char + else + translation << braille.translate_word(char) + end + end + translation.join + end +end + +BrailleEncoder.new.run \ No newline at end of file diff --git a/modules/encoders/cipher/braille/secgen_metadata.xml b/modules/encoders/cipher/braille/secgen_metadata.xml new file mode 100644 index 000000000..d81127dd8 --- /dev/null +++ b/modules/encoders/cipher/braille/secgen_metadata.xml @@ -0,0 +1,28 @@ + + + + Braille Code Encoder + Thomas Shaw + MIT + Encodes a string into Braille. + + braille_encoder + ascii_reversible + string_encoder + linux + windows + + https://github.com/nicanor/braille + + Braille decoders are available online e.g. https://www.dcode.fr/braille-alphabet + + strings_to_encode + + + + + + encoded_strings +