#!/usr/local/bin/ruby # # This script allows you to encode a string or file using the # crypt-fog Ruby package. # # Author: # Daniel J. Berger # # Warranty: # This package is provided "as is" and without any express or # implied warranties, including, without limitation, the implied # warranties of merchantability and fitness for a particular purpose. # # License: Ruby's # # Copyright: (C) 2003-2005 Daniel J. Berger. All rights reserved. require "getoptlong" require "crypt/fog" include Crypt QUICKENC_VERSION = 1.1 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