Module: Keepassx::AESCrypt

Defined in:
lib/keepassx/aes_crypt.rb

Class Method Summary collapse

Class Method Details

.decrypt(encrypted_data, key, iv, cipher_type) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/keepassx/aes_crypt.rb', line 3

def self.decrypt(encrypted_data, key, iv, cipher_type)
  aes = OpenSSL::Cipher::Cipher.new(cipher_type)
  aes.decrypt
  aes.key = key
  aes.iv = iv unless iv.nil?
  aes.update(encrypted_data) + aes.final
end

.encrypt(data, key, iv, cipher_type) ⇒ Object



11
12
13
14
15
16
17
# File 'lib/keepassx/aes_crypt.rb', line 11

def self.encrypt(data, key, iv, cipher_type)
  aes = OpenSSL::Cipher::Cipher.new(cipher_type)
  aes.encrypt
  aes.key = key
  aes.iv = iv unless iv.nil?
  aes.update(data) + aes.final
end