I am writing a function that needs to return a 'random' number from a given string, starting from:
function hashNumberBetween(str, start, end){
....
return num;
}
// same string and same length return same number
hashNumberBetween('getjnigejgr', 0, 10); // 4
hashNumberBetween('getjnigejgr', 0, 10); // 4
// but, same string and different length return different number
hashNumberBetween('getjnigejgr', 0, 32); // 15
hashNumberBetween('jukojmnktgo', 0, 10); // 6
what is the right way to achieve the same combination given the same string? I reckon it is some sort of hash function. Any online resource I can look at? Might sound a really easy question but I don't know how to search for it.