app/models/concerns/encryptable.rb
# Encrypts plain data using a 256-bit key represented as a 64 character
# hexadecimal string.
# `key_hex` is converted to 256-bit (32-byte) string for the cipher.
# The `encrypt` method returns a hex-encoded encrypted data string and a
# hex-encoded Initialization Vector (`iv`)
Encrypts plain data using a 256-bit key represented as a 64 character
hexadecimal string.
`key_hex` is converted to 256-bit (32-byte) string for the cipher.
The `encrypt` method returns a hex-encoded encrypted data string and a
hex-encoded Initialization Vector (`iv`)
Encrypts plain data using a 256 - bit key represented as a 64 character hexadecimal string . ` key_hex ` is converted to 256 - bit ( 32 - byte ) string for the cipher . The ` encrypt ` method returns a hex - encoded encrypted data string and a hex - encoded Initialization Vector ( ` iv ` )
def encrypt(data, key_hex)
    key = hex_to_bytes(key_hex)
    (encrypted_data_bytes, iv_bytes) = encrypt_bytes(data, key)
    encrypted_data_hex = bytes_to_hex(encrypted_data_bytes)
    iv_hex = bytes_to_hex(iv_bytes)
    [encrypted_data_hex, iv_hex]
  end
def encrypt ( data , key_hex ) key = hex_to_bytes ( key_hex ) ( encrypted_data_bytes , iv_bytes ) = encrypt_bytes ( data , key ) encrypted_data_hex = bytes_to_hex ( encrypted_data_bytes ) iv_hex = bytes_to_hex ( iv_bytes ) [ encrypted_data_hex , iv_hex ] end
Encrypts plain data using a 256-bit key represented as a 64 character
hexadecimal string.
Encrypts plain data using a 256 - bit key represented as a 64 character hexadecimal string .
data
key_hex