Class: OnePassword::EncryptionKey

Inherits:
Object
  • Object
show all
Defined in:
lib/one_password/encryption_key.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(profile, data) ⇒ EncryptionKey

Returns a new instance of EncryptionKey.


8
9
10
11
12
13
# File 'lib/one_password/encryption_key.rb', line 8

def initialize(profile, data)
  @profile = profile
  data.each do |name, value|
    send("#{name}=", value)
  end
end

Instance Attribute Details

#dataObject

noinspection RubyResolve


6
7
8
# File 'lib/one_password/encryption_key.rb', line 6

def data
  @data
end

#identifierObject

noinspection RubyResolve


6
7
8
# File 'lib/one_password/encryption_key.rb', line 6

def identifier
  @identifier
end

#iterationsObject

noinspection RubyResolve


6
7
8
# File 'lib/one_password/encryption_key.rb', line 6

def iterations
  @iterations
end

#levelObject

noinspection RubyResolve


6
7
8
# File 'lib/one_password/encryption_key.rb', line 6

def level
  @level
end

#profileObject

noinspection RubyResolve


6
7
8
# File 'lib/one_password/encryption_key.rb', line 6

def profile
  @profile
end

#validationObject

noinspection RubyResolve


6
7
8
# File 'lib/one_password/encryption_key.rb', line 6

def validation
  @validation
end

Instance Method Details

#decrypt(password = self.profile.password) ⇒ Object


22
23
24
# File 'lib/one_password/encryption_key.rb', line 22

def decrypt(password=self.profile.password)
  @decrypted_key = Encryption.decrypt_using_pbkdf2(data, password, iterations)
end

#decrypted_keyObject


26
27
28
# File 'lib/one_password/encryption_key.rb', line 26

def decrypted_key
  @decrypted_key || decrypt
end

#valid?Boolean

Returns:

  • (Boolean)

30
31
32
# File 'lib/one_password/encryption_key.rb', line 30

def valid?
  Encryption.decrypt_using_key(validation, decrypted_key) == decrypted_key
end