Module: EncryptionActivator
- Defined in:
- lib/encryption_activator.rb
Defined Under Namespace
Classes: KeyNotSetException
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.key ⇒ Object
37
38
39
|
# File 'lib/encryption_activator.rb', line 37
def key
keyproc.call
end
|
Class Method Details
.keyproc ⇒ Object
33
34
35
|
# File 'lib/encryption_activator.rb', line 33
def keyproc
lambda {|*opts| @key || ENV['ENCRYPTION_ACTIVATOR_KEY'] || raise(EncryptionActivator::KeyNotSetException.new("Key not set!")) }
end
|
.prompt(tty = STDIN) ⇒ Object
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/encryption_activator.rb', line 10
def prompt(tty=STDIN)
if tty.tty?
attempt1 = nil
3.times do
$stderr.print "Enter key: "
attempt1 = tty.noecho(&:gets).chomp
if attempt1.length < 20
$stderr.puts "not long enough, minimum 20 chars"
next
end
$stderr.print "\n Confirm: "
attempt2 = tty.noecho(&:gets).chomp
if attempt1 == attempt2
self.key = attempt1
break
end
$stderr.puts "did not match, try again"
end
end
end
|