Class: SecureYaml::Cipher

Inherits:
Object
  • Object
show all
Defined in:
lib/secure_yaml/cipher.rb

Instance Method Summary collapse

Instance Method Details

#decrypt(secret_key, encrypted_data) ⇒ Object



15
16
17
18
19
# File 'lib/secure_yaml/cipher.rb', line 15

def decrypt(secret_key, encrypted_data)
  cipher = create_cipher(secret_key)
  cipher.decrypt
  cipher.update(Base64.decode64(encrypted_data)) + cipher.final
end

#encrypt(secret_key, plain_data) ⇒ Object



9
10
11
12
13
# File 'lib/secure_yaml/cipher.rb', line 9

def encrypt(secret_key, plain_data)
  cipher = create_cipher(secret_key)
  cipher.encrypt
  strip_newline_chars_from_base64(Base64.encode64(cipher.update(plain_data) + cipher.final))
end