$:.unshift Dir.pwd + "/lib" require "getoptlong" require "crypt/fog" include Crypt QUICKENC_VERSION = 1.0 def usage print <<-HELP Usage: quickenc -f -d quickenc -s -d HELP exit end args = GetoptLong.new( ["--file", "-f", GetoptLong::OPTIONAL_ARGUMENT], ["--degree", "-d", GetoptLong::REQUIRED_ARGUMENT], ["--string", "-s", GetoptLong::OPTIONAL_ARGUMENT], ["--version", "-v", GetoptLong::NO_ARGUMENT], ["--help", "-h", GetoptLong::NO_ARGUMENT] ) opts = {} begin args.each{ |option,value| opts[option] = value || true } rescue GetoptLong::InvalidOption usage() exit end if opts["--version"] puts "VERSION: " + QUICKENC_VERSION.to_s exit end if opts["--help"] usage() end unless opts["--file"] || opts["--string"] STDERR.puts "Must provide string or file name" usage() end unless opts["--degree"] STDERR.puts "Must provide a degree of salt" usage() end str = nil if opts["--file"] str = IO.readlines(opts["--file"]).flatten.to_s.chomp else str = opts["--string"] end salt = opts["--degree"].to_i puts puts "Copy and paste the string below to wherever you need it" puts "Remember your salt number (#{salt}) in order to decrypt it later on." puts "=" * 63 puts puts "Crypted string: " + Fog.new(str,salt).to_s puts