I'm completely new to ruby-on-rails, I just want to write a small rb programming code that will take input as a string(encoded password), then it will decode the string and return it to the caller. I was trying the below code but not sure what I'm doing, here my purpose of having this code is to use it as a plugin in fluentd.
def create_base_64
base64_string = "67382hfuisab3y289321787123890......"
decoded_data = StringIO.new(Base64.decode64(base64_string))
end
In case you are posting the code, could you please provide me with some online programming tool where I can test it online.
#!/usr/bin/env ruby
require 'base64'
def decode_string(encoded_string)
begin
Base64.decode64(encoded_string)
rescue
puts 'Not a base64 string'
exit
end
end
if ARGV.length != 1
puts 'Missing argument'
exit
end
puts decode_string(ARGV[0])