<commit_before>module Dianxin
  class Base

    def initialize(apid, key, product_id)
      @apid = apid
      @key = key
      @product_id = product_id
    end
    
    def sms(number, message)
      timestamp                           = Time.now.strftime('%Y%m%d%H%M%S')
      
      params                              = {}
      params['params']                    = {}
      params['params']['TimeStamp']       = timestamp
      params['params']['APID']            = @apid
      params['params']['Key']             = encrypt(timestamp+@apid, @key);
      params['params']['Num']             = number
      params['params']['Msg']             = message
      params['params']['IsReport']        = '0'
      params['params']['StatusReportUrl'] = 'http://114.80.110.16'
      params['params']['ProductID']       = @product_id
      params['params']['IsUse']           = '0'
      params['serviceId']                 = '00001020101130';
      params['params']['Parm1']           = "12"
      params['params']['Parm2']           = @product_id
      params['params']['Parm3']           = "56"
      
      puts params.inspect
      
      #do something with the message.
    end

  private
  
    def encrypt(message, key)
      key = Base64.decode64(key)
      puts "KEY: " + key
	  puts "MESSAGE: " + message
      cipher = OpenSSL::Cipher::Cipher.new("des-ede3")
      cipher.encrypt # Call this before setting key or iv
      cipher.key = key
      ciphertext = cipher.update(message) + cipher.final
      Base64.encode64(ciphertext)
    end
  
    def detect_encoding(string)
      @e = UniversalDetector::chardet(string)
      puts @e.inspect
      @e
    end
    
    def reencode(string, to, from)
      str = Iconv.new(to, from).iconv(string)<commit_msg>removing the end of line character<commit_after>module Dianxin
  class Base

    def initialize(apid, key, product_id)
      @apid = apid
      @key = key
      @product_id = product_id
    end
    
    def sms(number, message)
      timestamp                           = Time.now.strftime('%Y%m%d%H%M%S')
      
      params                              = {}
      params['params']                    = {}
      params['params']['TimeStamp']       = timestamp
      params['params']['APID']            = @apid
      params['params']['Key']             = encrypt(timestamp+@apid, @key);
      params['params']['Num']             = number
      params['params']['Msg']             = message
      params['params']['IsReport']        = '0'
      params['params']['StatusReportUrl'] = 'http://172.16.58.3'
      params['params']['ProductID']       = @product_id
      params['params']['IsUse']           = '0'
      params['serviceId']                 = '00001020101130';
      params['params']['Parm1']           = "12"
      params['params']['Parm2']           = @product_id
      params['params']['Parm3']           = "56"
      
      puts params.inspect
      
      #do something with the message.
    end

  private
  
    def encrypt(message, key)
      key = Base64.decode64(key)
      puts "KEY: " + key
	  puts "MESSAGE: " + message
      cipher = OpenSSL::Cipher::Cipher.new("des-ede3")
      cipher.encrypt # Call this before setting key or iv
      cipher.key = key
      ciphertext = cipher.update(message) + cipher.final
      Base64.encode64(ciphertext).gsub(/\n/, '')
    end
  
    def detect_encoding(string)
      @e = UniversalDetector::chardet(string)
      puts @e.inspect
      @e
    end
    
    def reencode(string, to, from)
      str = Iconv.new(to, from).iconv(string)
{'fraction_non_alphanumeric': 0.14080944350758853, 'fraction_numerical': 0.02304665542439573, 'mean_word_length': 1.8313444709626094, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '2442132', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1052, 'n_words': 206}