xxxxxxxxxx
28
function setup() {
createCanvas(400, 400);
console.log(hash("hello"));
console.log(hash("Hello"));
console.log(hash("Helllo"));
console.log(hash("goodbye"));
}
function draw() {
background(220);
}
function hash(str) {
let h = 0;
for(let i = 0; i < str.length; i ++) {
let c = (charCode(str[i]) ^ (i * i));
h ^= c;
}
return h;
}
function charCode(char) {
return char.charCodeAt(0);
}