EUI generator

Following from a mild thread hijack …

I’ve consulted with the author of that page and he says it’s not entirely random - for EUI’s it produces a properly formatted “locally administered address”. It is for the AppKey, but they are meant to be totally random.

Please see this

or this

// Kick start this browsers random number generator
let loop_da_loop = Math.floor(Math.random() * 100) + 25;
for (let c = 0; c < loop_da_loop; c++) { 
  let r = Math.random();
}


function createEUI() {

	var EUI = [

		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256)

	];

	EUI[0] = (EUI[0] & ~1) | 2;
	
	document.getElementById("type").innerHTML = "EUI";
	document.getElementById("justDigits").innerHTML = justDigits(EUI);
	document.getElementById("justDigitsUpper").innerHTML = justDigits(EUI).toUpperCase();
	document.getElementById("hexyDigitsUpper").innerHTML = hexyDigits(EUI);

}

function createKey() {

	var Key = [

		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256),
		Math.floor(Math.random() * 256)

	];
	
	document.getElementById("type").innerHTML = "Key";
	document.getElementById("justDigits").innerHTML = justDigits(Key);
	document.getElementById("justDigitsUpper").innerHTML = justDigits(Key).toUpperCase();
	document.getElementById("hexyDigitsUpper").innerHTML = hexyDigits(Key);

}

Does

Force the second digit (zero base counting) i.e. lower nibble of the most significant byte of the 16digit hex code to be a 2 thereby ensuring it gets recognised as a locally administered ‘address’/eui? (weak s/w skills here so always learning! :wink: ) If so I assume that the “2” could then be “6”, “A” or “E” for same effect?

I can’t write code, only copy and past :smiley:

Apart from the no small detail of being off topic for this thread, what is your actual point in quoting my own code to me??

You linked to it as a random generator, in a light hearted way I pointed out it was a little bit more than that. It’s OK to link to it as it is called and as you have done in the past, but it gives the wrong impression to call it a random generator. LoRaWAN is standards based, it’s not OK to give the impression that we can make things up.

And, as you may be aware, we don’t delete comments that take replies out of context.

Er, binary or two base counting, but yes, it sets that bit so that anything ending in 2, 6, A or E is valid.

Moving this debacle to another topic

:rofl: Welcome to my world! :slight_smile: Well I would add maybe edit a few values here and there as well ! :wink:

…even so you seem to manage to create some useful dashboards and overviews from previous discussions! :slight_smile: :+1:

But as Nick says off topic here…other than in the context of him being 1st to call out potential all zeros issue in 1st response to OP! :wink:

Post move update to add

“…1st response to OP on original thread!”