Skip to content

Instantly share code, notes, and snippets.

@Sharkbyteprojects
Last active August 17, 2021 15:49
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 Sharkbyteprojects/59b739dd14fcdc2ba82d836eff226393 to your computer and use it in GitHub Desktop.
Save Sharkbyteprojects/59b739dd14fcdc2ba82d836eff226393 to your computer and use it in GitHub Desktop.
Simple Random Lic Key gen (FORMAT: xxxx-xxxx-xxxx-xxxx)

Usage

you need to add kran.js to your script (copy content or use <script src="https://gist.githubusercontent.com/Sharkbyteprojects/59b739dd14fcdc2ba82d836eff226393/raw/27e9acf454d418db735d84ff2fc5319f1d42a47d/kran.js"></script>) before use, then

console.log(permut(rns())); will generate your key and output to console

function convert(integer) {
var str = Number(integer).toString(16);
return str.length == 1 ? "0" + str : str;
};
function rnd(max, min){
const mini=min?min:0;
return Math.round((Math.random()+mini)*max);
}
function rns(){
var perm = [];
for(let y=0;y<4;y++){
var arr = [];
for(let x = 0; x<2; x++){
arr.push(convert(rnd(0xff, 0x00)));
}
perm.push([arr]);
}
return perm;
}
function permut(r){
var s = "";
for(let x of r){
s+=x.join("") + "-";
}
s=s.split(",").join("");
return s.substring(0, s.length - 1);;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment