<commit_before>require 'tmpdir'
require 'securerandom'
require 'tempfile'
require 'zip'

module Aescrypt
  class Wrapper
    def encrypt_file(file, password: nil)
      execute(file: file, password: password)
    end

    def encrypt_files(files, password: nil)
      zip_file = Dir.tmpdir + "/#{SecureRandom.uuid}.zip"
      Zip::File.open(zip_file, Zip::File::CREATE) do |zipfile|
        files.each do |filename|
          zipfile.add(File.basename(filename), filename)
        end
      end

      execute(file: zip_file, password: password)
    ensure
      File.delete(zip_file)
    end

    def encrypt_string(data, password: nil)
      temp_file = Tempfile.new('encrypted_string')
      temp_file.write(data)
      temp_file.close
      execute(file: temp_file.path, password: password)
    ensure
      temp_file.unlink
    end

    private

    def bundled_binary
      File.dirname(__FILE__) + "/../bin/aescrypt"
    end

    def environment
      {"PATH" => File.dirname(__FILE__) + "/../bin"}
    end

    def execute(options = {})
      out_file = options[:out_file] || Dir.tmpdir + "/#{SecureRandom.uuid}.aes"
      password = options[:password] || <PASSWORD>
      input_file = options[:file]
      system(environment, bundled_binary, "-e", "-p", password, "-o", out_file, *input_file)
      {<commit_msg>Tweaking the command line slightly<commit_after>require 'tmpdir'
require 'securerandom'
require 'tempfile'
require 'zip'

module Aescrypt
  class Wrapper
    def encrypt_file(file, password: nil)
      execute(file: file, password: password)
    end

    def encrypt_files(files, password: nil)
      zip_file = Dir.tmpdir + "/#{SecureRandom.uuid}.zip"
      Zip::File.open(zip_file, Zip::File::CREATE) do |zipfile|
        files.each do |filename|
          zipfile.add(File.basename(filename), filename)
        end
      end

      execute(file: zip_file, password: password)
    ensure
      File.delete(zip_file)
    end

    def encrypt_string(data, password: nil)
      temp_file = Tempfile.new('encrypted_string')
      temp_file.write(data)
      temp_file.close
      execute(file: temp_file.path, password: password)
    ensure
      temp_file.unlink
    end

    private

    def bundled_binary
      File.dirname(__FILE__) + "/../bin/aescrypt"
    end

    def environment
      {"PATH" => File.dirname(__FILE__) + "/../bin"}
    end

    def execute(options = {})
      out_file = options[:out_file] || Dir.tmpdir + "/#{SecureRandom.uuid}.aes"
      password = options[:password] || <PASSWORD>
      input_file = options[:file]
      system(environment, bundled_binary, "-e", "-p #{password}", "-o", out_file, input_file)
      {
{'fraction_non_alphanumeric': 0.125, 'fraction_numerical': 0.0, 'mean_word_length': 2.9133627019089574, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '2096269', 'n_tokens_mistral': 856, 'n_tokens_neox': 829, 'n_words': 188}