lamchau
1/29/2014 - 3:05 PM

random sha1 string generator for testing

random sha1 string generator for testing

function sha1() {
  function random() {
    var characters = "abcdef0123456789";
    return (function () {
      var index = Math.floor(Math.random() * characters.length);
      return characters.charAt(index);
    })();
  }

  var MAX_LENGTH = 40;
  return (function () {
    var str = "";
    for (var i = 0; i < MAX_LENGTH; i++) {
      str += random();
    }
    return str;
  })();
};