Class: OpsWalrus::AgeEncryptionCipher
- Defined in:
- lib/opswalrus/hosts_file.rb
Instance Method Summary collapse
-
#decrypt(value) ⇒ Object
returns the decrypted text as a String.
-
#encrypt(value, audience_id_references) ⇒ Object
value is the string value to be encrypted audience_id_references is an Array(String) representing the names associated with public keys in the ids section of the file returns the encrypted text as a String.
- #encrypted?(value) ⇒ Boolean
-
#initialize(id_to_public_key_map, private_key_file_paths) ⇒ AgeEncryptionCipher
constructor
id_to_public_key_map is a Hash of id-name/(PublicKey | Array String ) pairs.
Methods inherited from Cipher
#dereference, #dereference_all
Constructor Details
#initialize(id_to_public_key_map, private_key_file_paths) ⇒ AgeEncryptionCipher
id_to_public_key_map is a Hash of id-name/(PublicKey | Array String ) pairs
293 294 295 296 |
# File 'lib/opswalrus/hosts_file.rb', line 293 def initialize(id_to_public_key_map, private_key_file_paths) super(id_to_public_key_map) @private_key_file_paths = private_key_file_paths end |
Instance Method Details
#decrypt(value) ⇒ Object
returns the decrypted text as a String
307 308 309 |
# File 'lib/opswalrus/hosts_file.rb', line 307 def decrypt(value) AgeEncryption.decrypt(value, @private_key_file_paths) end |
#encrypt(value, audience_id_references) ⇒ Object
value is the string value to be encrypted audience_id_references is an Array(String) representing the names associated with public keys in the ids section of the file returns the encrypted text as a String
301 302 303 304 |
# File 'lib/opswalrus/hosts_file.rb', line 301 def encrypt(value, audience_id_references) public_keys = dereference_all(audience_id_references) AgeEncryption.encrypt(value, public_keys.map(&:key)) end |
#encrypted?(value) ⇒ Boolean
311 312 313 |
# File 'lib/opswalrus/hosts_file.rb', line 311 def encrypted?(value) value.strip.start_with?(AgeEncryption::AGE_ENCRYPTED_FILE_HEADER) end |