Skip to content

Instantly share code, notes, and snippets.

@tianshuo
Last active December 12, 2015 04:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tianshuo/4713359 to your computer and use it in GitHub Desktop.
Save tianshuo/4713359 to your computer and use it in GitHub Desktop.
//This algorithm is from http://www.hellocq.net/forum/simple/?t284938.html
function dohash(theCall){
var hash=0x73e2;
var rootCall=theCall.split("-")[0].toUpperCase();
for(var i=0;i<rootCall.length;i+=2){
hash^=rootCall.charCodeAt(i)<<8;
hash^=rootCall.charCodeAt(i+1);
}
return hash & 0x7fff;
}
var theCall=prompt("Enter Your Number","BG6LKT");
var ans=dohash(theCall);
document.write(ans);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment