Class: EncryptedKeystore
- Inherits:
-
Object
- Object
- EncryptedKeystore
- Defined in:
- lib/encrypted_keystore.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
Returns the value of attribute file.
-
#iv ⇒ Object
Returns the value of attribute iv.
-
#key ⇒ Object
Returns the value of attribute key.
-
#out ⇒ Object
Returns the value of attribute out.
Class Method Summary collapse
Instance Method Summary collapse
- #decrypt ⇒ Object
- #encrypt ⇒ Object
-
#initialize(file: nil, out: nil, key: nil, iv: nil) ⇒ EncryptedKeystore
constructor
A new instance of EncryptedKeystore.
Constructor Details
#initialize(file: nil, out: nil, key: nil, iv: nil) ⇒ EncryptedKeystore
Returns a new instance of EncryptedKeystore.
21 22 23 24 25 26 |
# File 'lib/encrypted_keystore.rb', line 21 def initialize(file: nil, out: nil, key: nil, iv: nil) @file = file @out = out @key = key @iv = iv end |
Instance Attribute Details
#file ⇒ Object
Returns the value of attribute file.
7 8 9 |
# File 'lib/encrypted_keystore.rb', line 7 def file @file end |
#iv ⇒ Object
Returns the value of attribute iv.
7 8 9 |
# File 'lib/encrypted_keystore.rb', line 7 def iv @iv end |
#key ⇒ Object
Returns the value of attribute key.
7 8 9 |
# File 'lib/encrypted_keystore.rb', line 7 def key @key end |
#out ⇒ Object
Returns the value of attribute out.
7 8 9 |
# File 'lib/encrypted_keystore.rb', line 7 def out @out end |
Class Method Details
.decrypt(file: nil, out: nil, key: nil, iv: nil) ⇒ Object
16 17 18 19 |
# File 'lib/encrypted_keystore.rb', line 16 def self.decrypt(file: nil, out: nil, key: nil, iv: nil) enc = new(file: file, out: out, key: key, iv: iv) enc.decrypt end |
.encrypt(file: nil, out: nil) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/encrypted_keystore.rb', line 9 def self.encrypt(file: nil, out: nil) enc = new(file: file, out: out) enc.encrypt { key: enc.key, iv: enc.iv } end |
Instance Method Details
#decrypt ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/encrypted_keystore.rb', line 28 def decrypt validate write(dec_cipher) FileUtils.chmod(0o0600, @out) @out end |
#encrypt ⇒ Object
36 37 38 39 40 |
# File 'lib/encrypted_keystore.rb', line 36 def encrypt validate(enc: true) write(enc_cipher) end |