Sha256: c31aa5f962b8a9ce6f230eab9f7111820132a9e889b49e7585bd8f3d43519018

Contents?: true

Size: 721 Bytes

Versions: 1

Compression:

Stored size: 721 Bytes

Contents

# frozen_string_literal: true

module Keepassx
  module AESCrypt
    module_function

    # rubocop:disable Naming/MethodParameterName
    def decrypt(encrypted_data, key, iv, cipher_type)
      aes = OpenSSL::Cipher.new(cipher_type)
      aes.decrypt
      aes.key = key
      aes.iv  = iv unless iv.nil?
      aes.update(encrypted_data) + aes.final
    end
    # rubocop:enable Naming/MethodParameterName


    # rubocop:disable Naming/MethodParameterName
    def encrypt(data, key, iv, cipher_type)
      aes = OpenSSL::Cipher.new(cipher_type)
      aes.encrypt
      aes.key = key
      aes.iv  = iv unless iv.nil?
      aes.update(data) + aes.final
    end
    # rubocop:enable Naming/MethodParameterName

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
keepassx-1.1.0 lib/keepassx/aes_crypt.rb