<commit_before>var GLCrypto = {};

GLCrypto.getRandomBytes = function () {
  // This code is taken from cryptocat.
  var buffer, crypto;
  // Node.js ... for tests
  if (typeof window === 'undefined' && typeof require !== 'undefined') {
    crypto = require('crypto');
    try {
      buffer = crypto.randomBytes(40)
    } catch (e) {
      throw e
    }
  }
  // Older versions of Firefox
  else if (navigator.userAgent.match('Firefox') &&
    (!window.crypto || !window.crypto.getRandomValues)
    ) {
    var element = document.createElement('cryptocatFirefoxElement');
    document.documentElement.appendChild(element);
    var evt = document.createEvent('HTMLEvents');
    evt.initEvent('cryptocatGenerateRandomBytes', true, false);
    element.dispatchEvent(evt);
    buffer = element.getAttribute('randomValues').split(',');
    element = null
  }
  // Browsers that don't require workarounds
  else {
    buffer = new Uint8Array(40);
    window.crypto.getRandomValues(buffer)
  }
  return buffer
};

GLCrypto.randomString = function (length) {
  var possibleChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
    randomBytes = GLCrypto.getRandomBytes(),
    result = '';

  for (var i = 0; i < length; i++) {
    var idx = i;
    // If we have already covered all possible values then we need to generate
    // some new bytes.
    if (idx > randomBytes.length) {
      randomBytes = GLCrypto.getRandomBytes();
      idx = idx % randomBytes.length;
    }
    ;
    result += possibleChars[randomBytes[idx] % possibleChars.length];
  }
  ;
  return result;
};
<commit_msg>corrected wizard password generator (forced to contain both numbers and letters)<commit_after>var GLCrypto = {};

GLCrypto.getRandomBytes = function () {
  // This code is taken from cryptocat.
  var buffer, crypto;
  // Node.js ... for tests
  if (typeof window === 'undefined' && typeof require !== 'undefined') {
    crypto = require('crypto');
    try {
      buffer = crypto.randomBytes(40)
    } catch (e) {
      throw e
    }
  }
  // Older versions of Firefox
  else if (navigator.userAgent.match('Firefox') &&
    (!window.crypto || !window.crypto.getRandomValues)
    ) {
    var element = document.createElement('cryptocatFirefoxElement');
    document.documentElement.appendChild(element);
    var evt = document.createEvent('HTMLEvents');
    evt.initEvent('cryptocatGenerateRandomBytes', true, false);
    element.dispatchEvent(evt);
    buffer = element.getAttribute('randomValues').split(',');
    element = null
  }
  // Browsers that don't require workarounds
  else {
    buffer = new Uint8Array(40);
    window.crypto.getRandomValues(buffer)
  }
  return buffer
};

GLCrypto.randomString = function (length) {
  var possibleChars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789',
    randomBytes = GLCrypto.getRandomBytes(),
    result = '';

  do {
    result = '';

    randomBytes = GLCrypto.getRandomBytes();

    for (var i = 0; i < length; i++) {
      var idx = i;
      // If we have already covered all possible values then we need to generate
      // some new bytes.
      if (idx > randomBytes.length) {
        randomBytes = GLCrypto.getRandomBytes();
        idx = idx % randomBytes.length;
      };
      result += possibleChars[randomBytes[idx] % possibleChars.length];
    }
    
    // the strings are checked to contains both characters and numbers
  } while((result.match(/^[A-Za-z]*$/) && result.match(/^[\d]*$/)));

  return result;
};

{'fraction_non_alphanumeric': 0.1280365818805373, 'fraction_numerical': 0.009145470134324093, 'mean_word_length': 3.23728813559322, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1507183', 'n_tokens_mistral': 1104, 'n_tokens_neox': 1066, 'n_words': 258}