AesGcm::SequelColumnEncryption
Module for decrypting data encrypted with the Sequel column encryption plugin
This module provides utilities to decrypt data encrypted using Ruby's sequel-column-encryption gem, which is commonly used for encrypting database columns in Sequel ORM applications.
Example:
key = ENV["SEQUEL_COLUMN_ENCRYPTION_KEY"]
encrypted = "AAAAAM4LImpq..." # Base64 encoded encrypted data
decrypted = AesGcm::SequelColumnEncryption.decrypt(encrypted, key)
puts decrypted # => "John Doe"
Constants
IV_SIZE = 12
KEY_PART_SIZE = 32
Component sizes
LOWERCASE_SEARCHABLE = 2_u8
MIN_SIZE_NOT_SEARCHABLE = 65
Minimum sizes for encrypted data based on format
MIN_SIZE_SEARCHABLE = 97
NOT_SEARCHABLE = 0_u8
Encryption format flags
SEARCHABLE = 1_u8
TAG_SIZE = 16
Class methods
Decrypt data encrypted in Sequel column encryption format
Parameters:
- data_base64: Base64-encoded encrypted data (String)
- key: Encryption key (String or Bytes)
- remove_padding: Whether to remove Sequel padding (default: true)
Returns: Decrypted plaintext as String
Raises: DecryptionError if data is invalid or decryption fails
decrypt_with_info(data_base64 : String, key : String | Bytes) : NamedTuple(plaintext: String, flags: UInt8, key_id: UInt8, searchable: Bool, format: String)
Decrypt data and return detailed information about the encryption format
Parameters:
- data_base64: Base64-encoded encrypted data (String)
- key: Encryption key (String or Bytes)
Returns: NamedTuple with decrypted data and metadata