So I got a integer variable between 1 and 10,000.
I'd like to convert every number to a unique! hash value that has a fixed length and has a custom charset (includes all alphabetic lowercase and uppercase characters).
So:
n=10could get toresult="AVduujANNiO"n=4507could get toresult="BciidEPpaEo"
I do not really know how to develop an algorithm like this so this is all I got so far. I think the algorithm should work but of course I get a integer value as hash - not a alphabetic value. No idea how to fix this and how to pad the result to give it a fixed length.
I really hope somebody is able to help me.
let value = "3325";
var getHash = function(value) {
let hash = 0;
for (let i = 0; i < value.length; i++) {
let char = value.charCodeAt(i);
hash = (hash << 6) + char + (char << 14);
hash=-hash
} return hash;
};
console.log(getHash(value))