Class: YamlVault::Main
- Inherits:
-
Object
- Object
- YamlVault::Main
- Defined in:
- lib/yaml_vault.rb
Class Method Summary collapse
Instance Method Summary collapse
- #decrypt ⇒ Object
- #decrypt_hash ⇒ Object
- #decrypt_yaml ⇒ Object
- #encrypt ⇒ Object
- #encrypt_hash ⇒ Object
- #encrypt_yaml ⇒ Object
-
#initialize(yaml_content, keys, cryptor_name = nil, prefix = nil, suffix = nil, passphrase: nil, sign_passphrase: nil, salt: nil, cipher: "aes-256-cbc", key_len: 32, signature_key_len: 64, digest: "SHA256", aws_kms_key_id: nil, aws_region: nil, aws_access_key_id: nil, aws_secret_access_key: nil, aws_profile: nil, gcp_kms_resource_id: nil, gcp_credential_file: nil) ⇒ Main
constructor
A new instance of Main.
Constructor Details
#initialize(yaml_content, keys, cryptor_name = nil, prefix = nil, suffix = nil, passphrase: nil, sign_passphrase: nil, salt: nil, cipher: "aes-256-cbc", key_len: 32, signature_key_len: 64, digest: "SHA256", aws_kms_key_id: nil, aws_region: nil, aws_access_key_id: nil, aws_secret_access_key: nil, aws_profile: nil, gcp_kms_resource_id: nil, gcp_credential_file: nil) ⇒ Main
Returns a new instance of Main.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/yaml_vault.rb', line 24 def initialize( yaml_content, keys, cryptor_name = nil, prefix = nil, suffix = nil, passphrase: nil, sign_passphrase: nil, salt: nil, cipher: "aes-256-cbc", key_len: 32, signature_key_len: 64, digest: "SHA256", aws_kms_key_id: nil, aws_region: nil, aws_access_key_id: nil, aws_secret_access_key: nil, aws_profile: nil, gcp_kms_resource_id: nil, gcp_credential_file: nil ) @yaml = yaml_content @keys = keys @prefix = prefix @suffix = suffix @passphrase = passphrase @sign_passphrase = sign_passphrase @salt = salt.to_s @cipher = cipher @key_len = key_len @signature_key_len = signature_key_len @digest = digest @aws_kms_key_id = aws_kms_key_id @aws_region = aws_region @aws_access_key_id = aws_access_key_id @aws_secret_access_key = aws_secret_access_key @aws_profile = aws_profile @gcp_kms_resource_id = gcp_kms_resource_id @gcp_credential_file = gcp_credential_file @cryptor = get_cryptor(cryptor_name) end |
Class Method Details
.from_file(filename, keys, cryptor_name = nil, prefix = nil, suffix = nil, **options) ⇒ Object
16 17 18 19 |
# File 'lib/yaml_vault.rb', line 16 def from_file(filename, keys, cryptor_name = nil, prefix = nil, suffix = nil, **) yaml_content = ERB.new(File.read(filename)).result new(yaml_content, keys, cryptor_name, prefix, suffix, **) end |
Instance Method Details
#decrypt ⇒ Object
60 61 62 63 |
# File 'lib/yaml_vault.rb', line 60 def decrypt parser = YAML::Parser.new(YamlVault::YAMLTreeBuilder.new(@keys, @prefix, @suffix, @cryptor, :decrypt)) parser.parse(@yaml).handler.root end |
#decrypt_hash ⇒ Object
69 70 71 |
# File 'lib/yaml_vault.rb', line 69 def decrypt_hash decrypt.to_ruby[0] end |
#decrypt_yaml ⇒ Object
77 78 79 |
# File 'lib/yaml_vault.rb', line 77 def decrypt_yaml decrypt.to_yaml end |
#encrypt ⇒ Object
55 56 57 58 |
# File 'lib/yaml_vault.rb', line 55 def encrypt parser = YAML::Parser.new(YamlVault::YAMLTreeBuilder.new(@keys, @prefix, @suffix, @cryptor, :encrypt)) parser.parse(@yaml).handler.root end |
#encrypt_hash ⇒ Object
65 66 67 |
# File 'lib/yaml_vault.rb', line 65 def encrypt_hash encrypt.to_ruby[0] end |
#encrypt_yaml ⇒ Object
73 74 75 |
# File 'lib/yaml_vault.rb', line 73 def encrypt_yaml encrypt.to_yaml end |