randHex.js 364 B

12345678910111213141516171819
  1. var choice = require('./choice');
  2. var _chars = '0123456789abcdef'.split('');
  3. /**
  4. * Returns a random hexadecimal string
  5. */
  6. function randHex(size){
  7. size = size && size > 0? size : 6;
  8. var str = '';
  9. while (size--) {
  10. str += choice(_chars);
  11. }
  12. return str;
  13. }
  14. module.exports = randHex;