Module: Rex::Crypto::Aes256

Defined in:
lib/rex/crypto/aes256.rb

Class Method Summary collapse

Class Method Details

.decrypt_aes256(iv, key, value) ⇒ String

Returns a decrypted string using AES256-CBC.

Parameters:

  • iv (String)

    Initialization vector.

  • key (String)

    Secret key.

Returns:

  • (String)

    The decrypted string.


24
25
26
27
28
29
30
# File 'lib/rex/crypto/aes256.rb', line 24

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

.encrypt_aes256(iv, key, value) ⇒ String

Returns an encrypted string using AES256-CBC.

Parameters:

  • iv (String)

    Initialization vector.

  • key (String)

    Secret key.

Returns:

  • (String)

    The encrypted string.


11
12
13
14
15
16
17
# File 'lib/rex/crypto/aes256.rb', line 11

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