Class: OnePassword::EncryptionKey
- Inherits:
-
Object
- Object
- OnePassword::EncryptionKey
- Defined in:
- lib/one_password/encryption_key.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
noinspection RubyResolve.
-
#identifier ⇒ Object
noinspection RubyResolve.
-
#iterations ⇒ Object
noinspection RubyResolve.
-
#level ⇒ Object
noinspection RubyResolve.
-
#profile ⇒ Object
noinspection RubyResolve.
-
#validation ⇒ Object
noinspection RubyResolve.
Instance Method Summary collapse
- #decrypt(password = self.profile.password) ⇒ Object
- #decrypted_key ⇒ Object
-
#initialize(profile, data) ⇒ EncryptionKey
constructor
A new instance of EncryptionKey.
- #valid? ⇒ Boolean
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
#data ⇒ Object
noinspection RubyResolve
6 7 8 |
# File 'lib/one_password/encryption_key.rb', line 6 def data @data end |
#identifier ⇒ Object
noinspection RubyResolve
6 7 8 |
# File 'lib/one_password/encryption_key.rb', line 6 def identifier @identifier end |
#iterations ⇒ Object
noinspection RubyResolve
6 7 8 |
# File 'lib/one_password/encryption_key.rb', line 6 def iterations @iterations end |
#level ⇒ Object
noinspection RubyResolve
6 7 8 |
# File 'lib/one_password/encryption_key.rb', line 6 def level @level end |
#profile ⇒ Object
noinspection RubyResolve
6 7 8 |
# File 'lib/one_password/encryption_key.rb', line 6 def profile @profile end |
#validation ⇒ Object
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_key ⇒ Object
26 27 28 |
# File 'lib/one_password/encryption_key.rb', line 26 def decrypted_key @decrypted_key || decrypt end |
#valid? ⇒ 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 |