tokeylic-gen v1.0.0
ToKeyLic-Gen
ToKeyLic-Gen is a cool library to generate tokens, licenses, keys and much more.
Getting Started
npm install ToKeyLic-GenOverview
ToKeyLic-Gen is made to be handfull and available for everyone. Imagine you have an API that needs authentication, well using this module will surelly help you to create simple auth tokens and make your API safe to use.
Key Options
keyLenght {Integer}
Choose the length of your keyDefault: 50 | Example: { keyLenght: 20 } | Content: abcdefghijklmnopqrstuvwxyz
useNumbers {Boolean}
Add numbers or not to your keyDefault: false | Example: { useNumbers: true } | Content: 0123456789
useSymbols {Boolean}
Add symbols or not to your keyDefault: false | Example: { useSymbols: true } | Content: `~!@#$%^&*()–_=+[]{}|;:‘“,./<>?
caps {String}
Choose between [none | mix | all]Default: mix | Example: { caps: "all" }
Token Options
You can also add the key options in the same object. (See example)
numberOfParts {Integer}
Choose the number of parts in your tokenDefault: 4 | Example: { numberOfParts: 5 }
minPartLength {Integer}
The minimum length of a part in your tokenDefault: 3 | Example: { minPartLength: 5 }
maxPartLength {Integer}
The maximum length of a part in your tokenDefault: 10 | Example: { maxPartLength: 5 }
separator {String}
The character that separates the parts in your tokenDefault: - | Example: { separator: "_" }
extras {String}
An array of characters which will be added at the end of each partDefault: [] | Example: { separator: "a", "b", "0", "13" }
License Options
You can also add the key options in the same object. (See example)
useParts {Boolean}
Add parts or not to your licenseDefault: false | Example: { useParts: true }
numberOfParts {Integer}
Choose the number of parts in your licenseDefault: 4 | Example: { numberOfParts: 5 }
minPartLength {Integer}
The minimum length of a part in your licenseDefault: 3 | Example: { minPartLength: 5 }
maxPartLength {Integer}
The maximum length of a part in your licenseDefault: 10 | Example: { maxPartLength: 5 }
prefix {String}
The prefix that you want to add in the begining of your licenseDefault: LIC | Example: { prefix: "FREE" }
prefixSeparator {String}
The character that separates the prefix in your tokenDefault: - | Example: { prefixSeparator: "_" }
partSeparator {String}
The character that separates the prefix in your tokenDefault: _ | Example: { partSeparator: "-" }
extras {String}
An array of characters which will be added at the end of each partDefault: [] | Example: { separator: "a", "b", "0", "13" }
Examples
Key Generation:
Simple Key Generation:
const { Key } = require("tokeylic-gen");
const key = new Key().gen();
console.log(key);Type: String Example Output: AhfEYSWmuqpdEeLLTeXGGqimRKYeuKjQNOPDfcKsBsWQjZozZc
Customised Key Generation:
const { Key } = require("tokeylic-gen");
const key = new Key({
keyLenght: 20,
useNumbers: true,
useSymbols: true,
caps: "mix"
}).gen();
console.log(key);Type: String Example Output: Yb%wG![<rgqr}:PqPX3Ie@Z<kymEAuQWlzcGtQw#SH~Y0IrRaC)
Token Generation
Simple Token Generation:
const { Token } = require("tokeylic-gen");
const token = new Token().gen();
console.log(token);Type: String Example Output: mbxlJxIUq-SliMAJ-zFjBkOl-uIkoToqPXE)
Customised Token Generation:
const { Token } = require("tokeylic-gen");
const token = new Token({
keyOptions: {
useNumbers: true,
useSymbols: true,
caps: "mix",
},
tokenOptions: {
numberOfParts: 5,
minPartLength: 3,
maxPartLength: 5,
extras: ["KEYGEN"]
}
}).gen()
console.log(token);Type: String Example Output: [<fJKEYGEN-YBa8nKEYGEN-sRK7KEYGEN-qxxkKEYGEN-:<w]KEYGEN)
License Generation
Simple License Generation:
const { License } = require("tokeylic-gen");
const license = new License().gen();
console.log(license);Type: String Example Output: LIC-vrPhLLGQdsKzQkTSzcGqVTOznJnuTmLjnsWhDZpYRdQUDQOJvB)
Customised License Generation:
const { License } = require("tokeylic-gen");
const license = new License({
keyOptions: {
useNumbers: true,
useSymbols: true,
caps: "mix",
},
licenseOptions: {
prefix: "KEYGEN",
partSeparator: "_",
useParts: true,
numberOfParts: 5,
minPartLength: 3,
maxPartLength: 5,
extras: ["KEYGEN"]
}
}).gen()
console.log(license);Type: String Example Output: KEYGEN-<hQ}KEYGEN_uOPKEYGEN_%yfKEYGEN_=raKEYGEN_P+lbKEYGEN)
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality.
Module License
This module is licensed under MIT license.
Thanks
Made by @TsWin and @matheo-debal with ❤️
4 years ago