def encrypt(str, random_iv: SymmetricEncryption.randomize_iv?, compress: false, header: always_add_header)
      return if str.nil?

      str = str.to_s
      return str if str.empty?

      encrypted = binary_encrypt(str, random_iv: random_iv, compress: compress, header: header)
      encode(encrypted)
    end
def encrypt(str, random_iv: SymmetricEncryption.randomize_iv?, compress: false, header: always_add_header)
      return if str.nil?

      str = str.to_s
      return str if str.empty?

      encrypted = binary_encrypt(str, random_iv: random_iv, compress: compress, header: header)
      encode(encrypted)
    end
Encrypt and then encode a string

 Returns data encrypted and then encoded according to the encoding setting
         of this cipher
 Returns nil if str is nil
 Returns "" str is empty

 Parameters

   str [String]
     String to be encrypted. If str is not a string, #to_s will be called on it
     to convert it to a string

   random_iv [true|false]
     Whether the encypted value should use a random IV every time the
     field is encrypted.
     Notes:
     * Setting random_iv to true will result in a different encrypted output for
       the same input string.
     * It is recommended to set this to true, except if it will be used as a lookup key.
     * Only set to true if the field will never be used as a lookup key, since
       the encrypted value needs to be same every time in this case.
     * When random_iv is true it adds the random IV string to the header.
     Default: false
     Highly Recommended where feasible: true

   compress [true|false]
     Whether to compress str before encryption.
     Default: false
     Notes:
     * Should only be used for large strings since compression overhead and
       the overhead of adding the encryption header may exceed any benefits of
       compression