anton-keygen-pro

1.0.9Β β€’Β PublicΒ β€’Β Published

anton-keygen-pro πŸ”‘

anton-keygen-pro is a Node.js module designed to generate different types of keys with customizable formats. This module is perfect for developers who need reliable and random key generation for their applications.

Installation

To install this package, simply run the following command in your project directory:

npm install anton-keygen-pro

Usage

After installation, you can require the package and use it to generate different types of keys.

const anton = require('anton-keygen-pro');

console.log(anton.key1);  // Outputs an alphanumeric key
console.log(anton.key7);  // Outputs a random hexadecimal key
console.log(anton.key8);  // Outputs an encrypted key with salt

Example Output

{
  key1: '72QS-M6T0-R5DD-I8T7',
  key2: 'NQYK-ATMB-ECVF-SJFH',
  key3: '5010-4021-5079-6396',
  key4: 'QSFR-GO7O-TFG3',
  key5: 'XMFB-TEEH-EXEX',
  key6: '5959-8095-5886',
  key7: '11ebde6d3fb485b363ba88cb279bd49c',
  key8: 'iCN2/tCfQMjVVLydkMi9fg==:GmSV8GXCbE9DF3G0p35srL9Dcpj+CqO+TnS6zmZXYY1YznkVlynYLkzKiRLM1AlE:334TIJKjcldWBKnqW3pdOw=='
}

Key Types

  • key1: Alphanumeric key (e.g., 'A1B2-C3D4-E5F6-G7H8')
  • key2: Alphabetic key (e.g., 'ABCD-EFGH-IJKL-MNOP')
  • key3: Numeric key (e.g., '1234-5678-9101-1121')
  • key4: Custom alphanumeric key with 3 segments (e.g., 'A1B2-C3D4-E5F6')
  • key5: Custom alphabetic key with 3 segments (e.g., 'ABCD-EFGH-IJKL')
  • key6: Custom numeric key with 3 segments (e.g., '1234-5678-9101')
  • key7: Random hexadecimal key (e.g., '9f86d081884c7d659a2feaa0c55ad015')
  • key8: Encrypted key with salt and IV for enhanced security.

Explanation of Key8

  • key8: This key combines salt, an encrypted key, and an initialization vector (IV) generated using cryptographic algorithms. It is designed to enhance security in key management, ensuring that the key is not only randomly generated but also encrypted to protect sensitive data.

    Format of Key8:

    {salt}:{encryptedKey}:{iv}
    
    • salt: A random string used in the encryption process to strengthen security.
    • encryptedKey: The encrypted key, which makes it unreadable without the proper decryption.
    • iv: An initialization vector used in the encryption algorithm to ensure that the encryption results are unique even if the same key is used multiple times.

Example Usage of Key8

const anton = require('anton-keygen-pro');

const key8 = anton.key8;  // Generates an encrypted key
console.log(`Key 8: ${key8}`);

// Split the key components if needed
const [salt, encryptedKey, iv] = key8.split(':');
console.log(`Salt: ${salt}`);
console.log(`Encrypted Key: ${encryptedKey}`);
console.log(`IV: ${iv}`);

Error Handling

The module includes error handling to ensure that invalid parameters or key types are caught and reported:

try {
  const invalidKey = generateKey(0, 4, ''); // This will throw an error
} catch (error) {
  console.error('Failed to generate key:', error.message);
}

License

This project is licensed under the MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! If you find any issues or have suggestions, feel free to submit a pull request or open an issue.

Testing

To run the tests, simply execute:

npm test

Package Sidebar

Install

npm i anton-keygen-pro

Weekly Downloads

6

Version

1.0.9

License

MIT

Unpacked Size

12.1 kB

Total Files

8

Last publish

Collaborators

  • antonthomzz