Sha256: dfec752c715bfa461c9d6b889619ca3e1785efaa4955afb9b9424a95eca6764b
Contents?: true
Size: 856 Bytes
Versions: 3
Compression:
Stored size: 856 Bytes
Contents
require 'bcdatabase/commands' require 'highline' module Bcdatabase::Commands class Epass def initialize(streaming, opts={}) @streaming = streaming @echo = opts[:echo].nil? ? false : opts[:echo] @hl = HighLine.new($stdin, $stderr) end def run @streaming ? streamed : interactive end protected def streamed $stdin.readlines.each do |line| puts Bcdatabase.encrypt(line.chomp) end end def interactive loop do pass = @hl.ask("Password (^C to end): ") do |q| # this is configurable because having it false hangs the # unit tests. q.echo = @echo end puts " epassword: #{Bcdatabase.encrypt(pass)}" end rescue Interrupt $stderr.puts "Quit" rescue EOFError $stderr.puts "Quit" end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
bcdatabase-1.2.1 | lib/bcdatabase/commands/epass.rb |
bcdatabase-1.2.0 | lib/bcdatabase/commands/epass.rb |
bcdatabase-1.1.0 | lib/bcdatabase/commands/epass.rb |