<commit_before>require 'uri'

class IbanRequest
  def initialize(config)
    @uri = URI.parse(config['url'])
    @ssl_verify = config['ssl_verify']
    @params = { 'user' => config['user'], 'password' => config['password'] }
  end

  def submit(params)
    http = Net::HTTP.new(@uri.host, @uri.port)
    http.use_ssl = true if @uri.scheme == 'https'
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_verify

    @request = Net::HTTP::Post.new(@uri.request_uri)
    @request.set_form_data(@params.merge(params))

    response = http.request(@request)
    IbanResponse.new(response)
  end
end<commit_msg>[ZOE-631]  Hash the password for transmission<commit_after>require 'digest'
require 'uri'

class IbanRequest
  def initialize(config)
    @uri = URI.parse(config['url'])
    @ssl_verify = config['ssl_verify']
    @params = { 'user' => config['user'], 'password' => config['password'] }
  end

  def submit(params)
    http = Net::HTTP.new(@uri.host, @uri.port)
    http.use_ssl = true if @uri.scheme == 'https'
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_verify

    @request = Net::HTTP::Post.new(@uri.request_uri)
    @request.set_form_data(hash_password(params))

    response = http.request(@request)
    IbanResponse.new(response)
  end

  def hash_password(params)
    params = @params.merge(params)
    password = params['function'] + params['user']
    password << case params['function']
                when 'calculate_iban' then params['account']
                when 'validate_iban' then params['iban']
                else fail "Unknown function: #{params['function']}"
                end
    password << params['password']
    params['password'] = Digest::MD5.hexdigest(password)
    params
  end
  private :hash_password

end
{'fraction_non_alphanumeric': 0.14737436476566912, 'fraction_numerical': 0.002258610954263128, 'mean_word_length': 3.7253333333333334, 'pattern_counts': {'":': 0, '<': 7, '<?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': '2988915', 'n_tokens_mistral': 570, 'n_tokens_neox': 550, 'n_words': 114}