function genHexString1(len) {
return Array.from(crypto.getRandomValues(new Uint8Array(len / 2 ))).map(b => b.toString(16).padStart(2, '0')).join('');
}
function genHexString2(len) {
const hex = '0123456789abcdef';
let output = '';
for (let i = 0; i < len; ++i) {
output += hex.charAt(Math.floor(Math.random() * hex.length));
}
return output;
}
function genHexString3(len) {
let arr = new Uint8Array((len / 2));
window.crypto.getRandomValues(arr);
return Array.from(arr, dec => ('0' + dec.toString(16)).substr(-2)).join('');
}
function genHexString4(len) {
const hexChars = '0123456789abcdef';
return [...Array(len)].map(() => hexChars[Math.floor(Math.random() * 16)]).join('');
}
function genHexString5(len) {
let arr = new Uint8Array(len / 2);
crypto.getRandomValues(arr);
return btoa(String.fromCharCode.apply(null, arr)).replace(/[^a-f0-9]/g, '').substr(0, len);
}