<commit_before>import logging
class NullHandler(logging.Handler):
    def emit(self, record):
        pass
log = logging.getLogger('coapUtils')
log.setLevel(logging.ERROR)
log.addHandler(NullHandler())

import traceback
import re

#===== trimming zeros on addresses

def trimAddress(address):
    return re.sub(
        pattern = r':0+([0-9A-Fa-f]+)',
        repl    = r':\1',
        string  = address,
    )

#===== converting

def int2buf(val,length):
    returnVal  = []
    for i in range(length,0,-1):
        returnVal += [val>>(8*(i-1))&0xff]
    return returnVal

def buf2int(buf):
    returnVal  = 0
    for i in range(len(buf)):
        returnVal += buf[i]<<(8*(len(buf)-1-i))
    return returnVal

def buf2str(buf):
    return ''.join([chr(b) for b in buf])

def str2buf(str):
    return [ord(b) for b in str]

#===== byte manipulation

def xorStrings(s1,s2):
    assert len(s1) == len(s2)
    return ''.join(chr(ord(a) ^ ord(b)) for a, b in zip(s1, s2))

def zeroPadString(s1, len):<commit_msg>COAP-46. utils: Add a method to xor bytes.<commit_after>import logging
class NullHandler(logging.Handler):
    def emit(self, record):
        pass
log = logging.getLogger('coapUtils')
log.setLevel(logging.ERROR)
log.addHandler(NullHandler())

import traceback
import re

#===== trimming zeros on addresses

def trimAddress(address):
    return re.sub(
        pattern = r':0+([0-9A-Fa-f]+)',
        repl    = r':\1',
        string  = address,
    )

#===== converting

def int2buf(val,length):
    returnVal  = []
    for i in range(length,0,-1):
        returnVal += [val>>(8*(i-1))&0xff]
    return returnVal

def buf2int(buf):
    returnVal  = 0
    for i in range(len(buf)):
        returnVal += buf[i]<<(8*(len(buf)-1-i))
    return returnVal

def buf2str(buf):
    return ''.join([chr(b) for b in buf])

def str2buf(str):
    return [ord(b) for b in str]

#===== byte manipulation

def xorBytes(b1, b2):
    parts = []
    for b1, b2 in zip(b1, b2):
        parts.append(bytes([b1 ^ b2]))
    return bytes(b''.join(parts))

def xorStrings(s1,s2):
    assert len(s1) == len(s2)
    return ''.join(chr(ord(a) ^ ord(b)) for a, b in zip(s1, s2))

def zeroPadString(s1, len):
{'fraction_non_alphanumeric': 0.1705532693187014, 'fraction_numerical': 0.025605852766346592, 'mean_word_length': 3.1835564053537286, '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': '6464718', 'n_tokens_mistral': 830, 'n_tokens_neox': 817, 'n_words': 198}