keygentoolshed
Version:
Key generation utilities for cryptographic operations. QUANTUM ENCRYPTION FOLDER UPDATE!!! See its folder for all <3
40 lines (34 loc) • 1 kB
JavaScript
function uid(length) {
const HEX = Array.from({ length: 36 }, (_, i) => i.toString(36)).join('');
let result = '';
for (let i = 0; i < (length || 11); i++) {
result += HEX[Math.floor(Math.random() * 36)];
}
return result;
}
export const xptagPrefix = () => uid(9);
export const xptagPrivate = (t, a) => xptag(t, a, true);
export function xptag(t, a, r) {
const e = a || uid(9);
const i = uid(16);
let x = r ? 3 : 1;
let o = '';
if (t) {
let a;
if (x | 4) {
x |= 4;
}
if (t < 0) {
x |= 8;
a = Math.ceil(-t / 5);
} else {
a = Math.ceil(Date.now() / 1000 / 60 / 5) + Math.ceil(t / 5);
}
o = a.toString(16);
}
return e + i + x.toString(16) + o;
}
if (import.meta.url === new URL(import.meta.url).href) {
console.log('Generated Prefix:', xptagPrefix());
console.log('Generated Private Key:', xptagPrivate(10)); // Example with a time parameter
}