<commit_before>package org.asyncmongo.utils

import org.jboss.netty.channel._
import org.jboss.netty.buffer._

import org.asyncmongo.protocol.ChannelBufferWritable

object `package` {
  def randomInt = (new java.util.Random()).nextInt(Integer.MAX_VALUE)
}

object Converters {
  private val HEX_CHARS :Array[Char] = "0123456789abcdef".toCharArray();

  def hex2Str(bytes: Array[Byte]) :String = {
    val hex = new Array[Char](2 * bytes.length)
    var i = 0
    while(i < bytes.length) {
      hex(2 * i) = HEX_CHARS((bytes(i) & 0xF0) >>> 4)
      hex(2 * i + 1) = HEX_CHARS(bytes(i) & 0x0F)
      i = i + 1
    }
    new String(hex)
  }

  def str2Hex(str: String) :Array[Byte] = {
    val bytes = new Array[Byte](str.length / 2)
    var i = 0
    while(i < bytes.length) {
      bytes(i) = Integer.parseInt(str.substring(i, i+2), 16).toByte
      i = i +1<commit_msg>corrected Converters.str2Hex + refactored Converters.hex2Str<commit_after>package org.asyncmongo.utils

import org.jboss.netty.channel._
import org.jboss.netty.buffer._

import org.asyncmongo.protocol.ChannelBufferWritable

object `package` {
  def randomInt = (new java.util.Random()).nextInt(Integer.MAX_VALUE)
}

object Converters {
  private val HEX_CHARS :Array[Char] = "0123456789abcdef".toCharArray();

  def hex2Str(bytes: Array[Byte]) :String = {
    bytes.map("%02X".format(_)).mkString
  }

  def str2Hex(str: String) :Array[Byte] = {
    val bytes = new Array[Byte](str.length / 2)
    var i = 0
    while(i < bytes.length) {
      bytes(i) = Integer.parseInt(str.substring(2*i, 2*i+2), 16).toByte
      i += 1
{'fraction_non_alphanumeric': 0.14510050251256282, 'fraction_numerical': 0.03329145728643216, 'mean_word_length': 3.590778097982709, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, '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': '7456848', 'n_tokens_mistral': 628, 'n_tokens_neox': 592, 'n_words': 119}