You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1.0 KiB

4 years ago
  1. /**
  2. * @fileoverview Defining the hashing function in one place.
  3. * @author Michael Ficarra
  4. */
  5. "use strict";
  6. //------------------------------------------------------------------------------
  7. // Requirements
  8. //------------------------------------------------------------------------------
  9. const murmur = require("imurmurhash");
  10. //------------------------------------------------------------------------------
  11. // Helpers
  12. //------------------------------------------------------------------------------
  13. //------------------------------------------------------------------------------
  14. // Private
  15. //------------------------------------------------------------------------------
  16. /**
  17. * hash the given string
  18. * @param {string} str the string to hash
  19. * @returns {string} the hash
  20. */
  21. function hash(str) {
  22. return murmur(str).result().toString(36);
  23. }
  24. //------------------------------------------------------------------------------
  25. // Public Interface
  26. //------------------------------------------------------------------------------
  27. module.exports = hash;