-2

I am building one application,in which I want to send unique code or referral code to each user.So I want to generate random strings from user mobile number.Each and every random string should be unique for each mobile number.How should I do that ? Is there any library for javascript or any good links for that ?

Steve Vinoski
  • 19,847
  • 3
  • 31
  • 46
Udit Kumawat
  • 654
  • 1
  • 8
  • 21

1 Answers1

0

In Node Js there are lots of packages available. You can also just use raw code like.

    String.prototype.hashCode = function() {
    var hash = 0, i, chr, len;
    if (this.length === 0) return hash;
    for (i = 0, len = this.length; i < len; i++) {
    chr   = this.charCodeAt(i);
      hash  = ((hash << 5) - hash) + chr;
      hash |= 0; // Convert to 32bit integer
      }
      return hash;
      };

This rudimentary hashing function will output a hash.