dist/harsh.js
function hash() {
  var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [Math.floor(Math.random() * 100)];
  var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
  var base = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 36;

  if (!ids.splice) {
    throw new TypeError('The ids argument should be an array of numbers');
  }
  if (typeof n !== 'number' || n < 0) {
    throw new TypeError('The number of salts should be a positive integer');
  }
  if (typeof base !== 'number' || base < 16 || base > 36) {
    throw new TypeError('The base should be a number between 16 and 36');
  }

  // Create the salts. This will be the same for all hashes
  var salts = _createSalts(n, base);

  // Combine the salts and the actual
  var hashes = ids.map(function (id) {
    if (typeof id !== 'number') {
      throw new TypeError('The ids you\'re hashing should only be numbers');
    }
    return _createHash(id, salts, base);
  });

  return {
    ids: ids,
    hashes: hashes,
    salts: salts,
    base: base
  };
}
function hash() {
  var ids = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [Math.floor(Math.random() * 100)];
  var n = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
  var base = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 36;

  if (!ids.splice) {
    throw new TypeError('The ids argument should be an array of numbers');
  }
  if (typeof n !== 'number' || n < 0) {
    throw new TypeError('The number of salts should be a positive integer');
  }
  if (typeof base !== 'number' || base < 16 || base > 36) {
    throw new TypeError('The base should be a number between 16 and 36');
  }

  // Create the salts. This will be the same for all hashes
  var salts = _createSalts(n, base);

  // Combine the salts and the actual
  var hashes = ids.map(function (id) {
    if (typeof id !== 'number') {
      throw new TypeError('The ids you\'re hashing should only be numbers');
    }
    return _createHash(id, salts, base);
  });

  return {
    ids: ids,
    hashes: hashes,
    salts: salts,
    base: base
  };
}
function hash ( ) { var ids = arguments . length > 0 && arguments [ 0 ] !== undefined ? arguments [ 0 ] : [ Math . floor ( Math . random ( ) * 100 ) ] ; var n = arguments . length > 1 && arguments [ 1 ] !== undefined ? arguments [ 1 ] : 2 ; var base = arguments . length > 2 && arguments [ 2 ] !== undefined ? arguments [ 2 ] : 36 ; if ( ! ids . splice ) { throw new TypeError ( 'The ids argument should be an array of numbers' ) ; } if ( typeof n !== 'number' || n < 0 ) { throw new TypeError ( 'The number of salts should be a positive integer' ) ; } if ( typeof base !== 'number' || base < 16 || base > 36 ) { throw new TypeError ( 'The base should be a number between 16 and 36' ) ; } // Create the salts. This will be the same for all hashes var salts = _createSalts ( n , base ) ; // Combine the salts and the actual var hashes = ids . map ( function ( id ) { if ( typeof id !== 'number' ) { throw new TypeError ( 'The ids you\'re hashing should only be numbers' ) ; } return _createHash ( id , salts , base ) ; } ) ; return { ids : ids , hashes : hashes , salts : salts , base : base } ; }
Takes a number and a radix base, outputs a salted hash
@param  {Array} ids   list of ids to hash
@param {Number} n number of salts to add to the hash
@param  {Number} base radix base, 16 through 36 allowed
@return {Object}      a hash object containing the hashes as well as info needed to reverse them
Takes a number and a radix base outputs a salted hash