Module: Vault::Rails
- Defined in:
- lib/vault/rails.rb,
lib/vault/rails/testing.rb,
lib/vault/rails/version.rb
Defined Under Namespace
Modules: Testing
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
- .decrypt(path, key, ciphertext) ⇒ Object
-
.decrypt_original ⇒ String
Decrypt the given ciphertext data using the provided mount and key.
- .encrypt(path, key, plaintext) ⇒ Object
-
.encrypt_original ⇒ String
Encrypt the given plaintext data using the provided mount and key.
Class Method Details
.decrypt(path, key, ciphertext) ⇒ Object
59 60 61 62 63 |
# File 'lib/vault/rails.rb', line 59 def self.decrypt(path, key, ciphertext) route = File.join(path, "decrypt", key) secret = Vault.logical.write(route, ciphertext: ciphertext) return Base64.strict_decode64(secret.data[:plaintext]) end |
.decrypt_original ⇒ String
Decrypt the given ciphertext data using the provided mount and key.
36 37 38 39 40 |
# File 'lib/vault/rails/testing.rb', line 36 def self.decrypt(path, key, ciphertext) route = File.join(path, "decrypt", key) secret = Vault.logical.write(route, ciphertext: ciphertext) return Base64.strict_decode64(secret.data[:plaintext]) end |
.encrypt(path, key, plaintext) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/vault/rails.rb', line 40 def self.encrypt(path, key, plaintext) route = File.join(path, "encrypt", key) secret = Vault.logical.write(route, plaintext: Base64.strict_encode64(plaintext), ) return secret.data[:ciphertext] end |
.encrypt_original ⇒ String
Encrypt the given plaintext data using the provided mount and key.
35 36 37 38 39 40 41 |
# File 'lib/vault/rails/testing.rb', line 35 def self.encrypt(path, key, plaintext) route = File.join(path, "encrypt", key) secret = Vault.logical.write(route, plaintext: Base64.strict_encode64(plaintext), ) return secret.data[:ciphertext] end |