A comprehensive utility library for generating unique identifiers, random strings, numbers, and secure tokens. This library provides customizable functions to generate registration numbers, SKUs, order IDs, ticket request IDs, tracking numbers, and more.
Install the package via npm:
npm install @astreak/unityimport { exmaple } = '@astreak/unity';Generate a secure and customizable registration number:
const registrationNumber = generateRegistrationNumber('USR', 6, true, true);
console.log(registrationNumber); // Example output: USR-L8FJP-A1B2C3Generate a secure and customizable SKU:
const sku = generateSKU('ELEC', 8, true, true);
console.log(sku); // Example output: ELEC-L8FJP-A1B2C3D4Generate a secure and customizable order ID:
const orderID = generateOrderID('ORD', 6, true, true);
console.log(orderID); // Example output: ORD-L8FJP-A1B2C3Generate a secure and customizable ticket ID:
const ticketID = generateTicketID('TCK', 6, true, true);
console.log(ticketID); // Example output: TCK-L8FJP-A1B2C3Generate a secure and customizable tracking number:
const trackingNumber = generateTrackingNumber('TRK', 8, true, true);
console.log(trackingNumber); // Example output: TRK-L8FJP-A1B2C3D4Generate a random string of a specified length:
const randomString = generateRandomString(10);
console.log(randomString); // Example output: a1b2c3d4e5Generate a random number within a specified range:
const randomNumber = generateRandomNumber(1, 100);
console.log(randomNumber); // Example output: 42Generate a random hexadecimal string of a specified length:
const randomHex = generateRandomHex(6);
console.log(randomHex); // Example output: a1b2c3Generate a random password of a specified length:
const randomPassword = generateRandomPassword(10);
console.log(randomPassword); // Example output: A1b2C3d4E5Generate a random token of a specified length:
const randomToken = generateRandomToken(16);
console.log(randomToken); // Example output: a1b2c3d4e5f6a7b8Generate a random initialization vector (IV) for encryption:
const randomIV = generateRandomIV();
console.log(randomIV); // Example output: a1b2c3d4e5f6a7b8c9d0e1f2