<commit_before># frozen_string_literal: true

require "openssl"
require "zlib"
require "active_support/core_ext/numeric"

module ActiveRecord
  module Encryption
    # An encryptor exposes the encryption API that +ActiveRecord::Encryption::EncryptedAttributeType+
    # uses for encrypting and decrypting attribute values.
    #
    # It interacts with a +KeyProvider+ for getting the keys, and delegate to
    # +ActiveRecord::Encryption::Cipher+ the actual encryption algorithm.
    class Encryptor
      # Encrypts +clean_text+ and returns the encrypted result
      #
      # Internally, it will:
      #
      # 1. Create a new +ActiveRecord::Encryption::Message+
      # 2. Compress and encrypt +clean_text+ as the message payload
      # 3. Serialize it with +ActiveRecord::Encryption.message_serializer+ (+ActiveRecord::Encryption::SafeMarhsal+
      #    by default)
      # 4. Encode the result with Base 64
      #
      # === Options
      #<commit_msg>Fix spelling in Encryptor.encrypt docs [ci skip]<commit_after># frozen_string_literal: true

require "openssl"
require "zlib"
require "active_support/core_ext/numeric"

module ActiveRecord
  module Encryption
    # An encryptor exposes the encryption API that +ActiveRecord::Encryption::EncryptedAttributeType+
    # uses for encrypting and decrypting attribute values.
    #
    # It interacts with a +KeyProvider+ for getting the keys, and delegate to
    # +ActiveRecord::Encryption::Cipher+ the actual encryption algorithm.
    class Encryptor
      # Encrypts +clean_text+ and returns the encrypted result
      #
      # Internally, it will:
      #
      # 1. Create a new +ActiveRecord::Encryption::Message+
      # 2. Compress and encrypt +clean_text+ as the message payload
      # 3. Serialize it with +ActiveRecord::Encryption.message_serializer+ (+ActiveRecord::Encryption::SafeMarshal+
      #    by default)
      # 4. Encode the result with Base 64
      #
      # === Options
      #
{'fraction_non_alphanumeric': 0.08193384223918575, 'fraction_numerical': 0.0061068702290076335, 'mean_word_length': 3.4681818181818183, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2137614', 'n_tokens_mistral': 565, 'n_tokens_neox': 536, 'n_words': 180}