Sha256: ac5c971faeaa61b028df76c39a87ff7eed61b672deb2979f654c0a15255e09e0

Contents?: true

Size: 820 Bytes

Versions: 1

Compression:

Stored size: 820 Bytes

Contents

# -*- coding: binary -*-

module Rex
  module Text

    # Returns an encrypted string using AES256-CBC.
    #
    # @param iv [String] Initialization vector.
    # @param key [String] Secret key.
    # @return [String] The encrypted string.
    def self.encrypt_aes256(iv, key, value)
      aes = OpenSSL::Cipher::AES256.new(:CBC)
      aes.encrypt
      aes.iv = iv
      aes.key = key
      aes.update(value) + aes.final
    end

    # Returns a decrypted string using AES256-CBC.
    #
    # @param iv [String] Initialization vector.
    # @param key [String] Secret key.
    # @return [String] The decrypted string.
    def self.decrypt_aes256(iv, key, value)
      aes = OpenSSL::Cipher::AES256.new(:CBC)
      aes.decrypt
      aes.iv = iv
      aes.key = key
      aes.update(value) + aes.final
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rex-text-0.2.18 lib/rex/text/aes256.rb