JSFiddle - React, Tailwind, and code Playground
by thelifeisyours
HTML
<input id="genButtn" type="button" name="genKey" value="Generate new key">
<input id="key" type="text" name="key" placeholder="New Key">
<a id="keyLink" href=""></a>
<br>
Length: <span id="lenght"></span>
JavaScript
$(document).ready(function(){
var count = 0;
function generateKey(){
var seed = 39946180,
chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ012345679!@#$^&%*()+=-_[]\/{}<>?",
rnum,
randNum = Math.floor(Math.random()*(99999999 - 0 + 1)),
keySeed = seed*randNum,
keySeedLength = keySeed.toString().length,
splitKeySeed,
keySeedArray = [],
key = [];
console.clear();
console.log('random num ='+randNum);
console.log('key seed = '+keySeed);
checkKeySeed();
//Function for checking the keySeed lenght
function checkKeySeed(){
if(keySeedLength != 16)
{
console.log('old keySeedLenght = '+keySeedLength);
console.log('old key seed = '+keySeed);
keySeed = seed* Math.floor(Math.random()*(99999999 - 11111111 + 1));
keySeedLength = keySeed.toString().length;
console.log('new key seed = '+keySeed);
console.log('new keySeedLenght = '+keySeedLength);
if(keySeedLength == 16)
{
splitKeySeed();
}
else
{
checkKeySeed();
}
}else
{
splitKeySeed();
}
}
//Function for spliting the keySeed
function splitKeySeed(){
for(var i = 0; i<keySeedLength; i+=2)
{
splitKeySeed = keySeed.toString().substr(i,2);
console.log('split key '+i+' = '+splitKeySeed);
keySeedArray.push(splitKeySeed);
}
console.log(keySeedArray);
//change keySeed to Key
for(var i = 0; i<keySeedArray.length; i++)
{
//keySeedArray[i];
...