Class: Cloak::Entry

Inherits:
Object
  • Object
show all
Defined in:
lib/cloak/entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(description = nil) ⇒ Entry

Initialise with secret



14
15
16
17
# File 'lib/cloak/entry.rb', line 14

def initialize(description = nil)
  @password = nil
  @description = description or raise 'Please enter a description of your entry'
end

Instance Attribute Details

#descriptionObject

Description



10
11
12
# File 'lib/cloak/entry.rb', line 10

def description
  @description
end

#passwordObject

Password in clear



6
7
8
# File 'lib/cloak/entry.rb', line 6

def password
  @password
end

Instance Method Details

#decrypt(key) ⇒ Object



25
26
27
28
# File 'lib/cloak/entry.rb', line 25

def decrypt(key)
  blowfish = Crypt::Blowfish.new(key)
  blowfish.decrypt_string(@password)
end

#encrypt(password_data, key) ⇒ Object



19
20
21
22
23
# File 'lib/cloak/entry.rb', line 19

def encrypt(password_data, key)
  blowfish = Crypt::Blowfish.new(key)
  @password = blowfish.encrypt_string(password_data)
  @password.force_encoding("BINARY")
end