Unique Profile id

Unque id on ui sid

by Nalin Sajwan

JavaScript

var getUuid = function(startText) {
	var buf = new Uint32Array(4);

			// Windows crypto is not available in IE 11 use msCrypto.
			// window.crypto.getRandomValues(buf);

			var cryptoObj = window.crypto || window.msCrypto;
			cryptoObj.getRandomValues(buf);

			var valueToReplace = 'xyxyxyxyxyxyxyxyxyxyxyxy';
			// var textToAdd = "";
			// if(startText !== undefined && startText.length > 0) {
			// 	startText = startText.trim().replace(/ /g,"");
			// 	textToAdd = startText.length > 5 ? startText.substring(0,5) : startText.trim().replace(/ /g, "");
			// 	valueToReplace = valueToReplace.substring(textToAdd.length);
			// }
			// console.log("valueToReplace ===>",valueToReplace);
			var idx = -1;
			return valueToReplace.replace(/[xy]/g, function(c) {
				// console.log("value of c ===>",c)
				idx++;
				var r = (buf[idx>>3] >> ((idx%8)*4))&15;
				var v = c == 'x' ? r : (r&0x3|0x8);
				return v.toString(16);
			});
};

profilesLength = 6;

var output = [];

for (var i = 0; i < profilesLength; i++) {
	output.push(getUuid());
	//console.log(getUuid());
};

console.log("Ids for ["+output.length+"] ===> ");
console.log(output.join("\n"));