npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

software-licence-key-without-fs

v1.0.2

Published

Library for generating and validating software license keys with data embedded in the key. Forked version without fs support.

Downloads

2

Readme

Software Licence Key Without FS

This is a library for generating and validating software license keys with data embedded in the license key. Fork from https://github.com/timtutt/software-license-key.

Installation

npm install software-license-key

Setup

You can then require the library in your code by using:

const SoftwareLicenseKey = require('software-license-key');

Usage

Crypto Key Generation

Key generation can be done manually or by leveraging the library. You can generate your own key pairs for usage by using the following commands:

#generate private key
openssl genpkey -algorithm RSA -out private_key.pem -pkeyopt rsa_keygen_bits:2048

#generate public key from private
openssl rsa -pubout -in private_key.pem -out public_key.pub

You can pass these keys to the library by calling the constructor with a parameter that is a buffer of the key itself.

  • With key external key files: use the original package (https://github.com/timtutt/software-license-key).

  • With string version of keys

var privateKey = "-----BEGIN RSA PRIVATE KEY-----\n" +
"MIIEogIBAAKCAQEAwYXYEB7ubL1nKk/V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kKtTPXq1cIBUIrB\n" +
"/Kq9EC9YPUvaVf41tptBJ6XB/VcES4MsjRJaWKkCgYAuo0Gkb0Jc1O7dZW8VeROO\n" +
"8PAbeERMNYCt+4zNHsJykJXRGIuV8P/7/gRt0BV5jcBaaz9O3leLND9md5L7R3eh\n" +
"nTSCyNV7zPCRqqBEH92DdX5lDIyhVh1t8+FSY/KiDkH/F1v/5vAII/iyqjBwov7E\n" +
"EEg4cL63wfqlgd5dAU70vwKBgARmMBnZhIB77ZkBpi8R7IjVa6ESJn/FgfCkQrW5\n" +
"kUc6hPVAEXGyyWQVltIZbrTHGbxlowUxJolf9geV9OsNMiTx1hamYRyHW5xkyTMx\n" +
"keItfKk+Pj2cAXCS/iYpImJ1SJHyaTiEcotmeP7YIli2nXDO5Rd0+DX5KJ52sv5U\n" +
"5pwBAoGAMNpoQcibyyjzuEAssiUP1QnyzxeM+o4PnbE02k8IRXLZoyHENkt+PQHN\n" +
"tqYo2Gf5rSMg/SaDCgBrHlOb2WbQPawiAewjkZxlMD2wFzp7/bhTn3cN45bEhn/l\n" +
"KyHMXak3IycYjYCznallCFUQ6OCiuTho+l891jTFuF/xgzI13EU=\n" +
"-----END RSA PRIVATE KEY-----";

var generator = new SoftwareLicenseKey(privateKey);

var publicKey = "-----BEGIN PUBLIC KEY-----\n" +
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwYXYEB7ubL1nKk/VltbQ\n" +
"TGU1WNvwpH9VgAO6ZZH2J0uKQXAYrDASO0OLsy/RnyWN+IS4hwr73KuxCppEG/6U\n" +
"OVlVKymCii/d5DrPjTnW5TtOD0hn/SxxyW1IKaPJbWzhxlpbPygfytDAwS2FTRsD\n" +
"em4SJVLxVERsAI1RkKnN1rCtWb+uV5PLga5ORAD0bCSniDdbEkkWLmWHgo6CYEUw\n" +
"UGDBXeqaXNEI+TXXZ+U3rIFejSZ8+6GVKd7GG72EL1MS110S2MHOkrFRlA7v+7Br\n" +
"tGGx2bWdoX13wp5s7DVhJmmeakiQLOs7P3QvMvUjfOOef5uem1wJmL16xfsPP1UZ\n" +
"xwIDAQAB\n" +
"-----END PUBLIC KEY-----";
var validator = new SoftwareLicenseKey(publicKey);
  • Library Generated Keys

If you'd prefer to have the library generate the key pairs for you, just instantiate it without passing a key.

var generator = new SoftwareLicenseKey();

Generating A License Key

To generate a license key you must instantiate with a private key or no key for automatic generation.

var generator = new SoftwareLicenseKey();
var licenseKeyData = {"fakeField": "some data"}
console.log(generator.generateLicense(licenseKeyData));

Validating A License Key

To validate a license key you must use the corresponding public key for the private key that generated the license key.

var publicKey = "-----BEGIN PUBLIC KEY-----\n" +
"MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAwYXYEB7ubL1nKk/VltbQ\n" +
"TGU1WNvwpH9VgAO6ZZH2J0uKQXAYrDASO0OLsy/RnyWN+IS4hwr73KuxCppEG/6U\n" +
"OVlVKymCii/d5DrPjTnW5TtOD0hn/SxxyW1IKaPJbWzhxlpbPygfytDAwS2FTRsD\n" +
"em4SJVLxVERsAI1RkKnN1rCtWb+uV5PLga5ORAD0bCSniDdbEkkWLmWHgo6CYEUw\n" +
"UGDBXeqaXNEI+TXXZ+U3rIFejSZ8+6GVKd7GG72EL1MS110S2MHOkrFRlA7v+7Br\n" +
"tGGx2bWdoX13wp5s7DVhJmmeakiQLOs7P3QvMvUjfOOef5uem1wJmL16xfsPP1UZ\n" +
"xwIDAQAB\n" +
"-----END PUBLIC KEY-----";

var validator = new SoftwareLicenseKey(publicKey);

var licenseKey = "====BEGIN LICENSE KEY====\n" +
"YgjrPp6+YEKin4Gox6CuEKwlu3qjvEGMu7GpelAjhnHLakQp9HdbzEZPMlFiD9++g1MKjCOu7lAwTpwXXIc/3YlsS2codN/piwAyx9HlbkCeXBk3PB+fOrv8a80Op7OZPTiY8As5YWrpfBLYZ79fOvsHqfZdc/i46aHYfX0NhW0K9RJfFgBFQRU1SaB4lDdOHedn2S6cBq5YyEgLBEIRPaheQR8/ojsa/KsI/oCC1m/0Jy1331aU/u/egGIGD8nh275zIoipJxmPzRszy6MRP8kTL+80NVneKWt7YFsNrQF9kvq6ggX9TijTsffJiUD2rkmRNVZ90LMPQKmg3eaL6g==||U2FsdGVkX1+29gUVOieMmxu/cfgZk9J4amjuzjX3aInFzubpSpSi/262FEyVmX/d\n" +
"ht0rbXKzg1gfRtnK1UU7cm+AyFKA0acCB+RN8F+GAkGFlUnH5YDI78j//IdPAWScqf5hEUIsrIC/RLIbKmDv8dWZ8+E7100xBt4IZ38IJ348Bcm0INcrfkjJNyj0okurWFjzubKCOcNxtEg931U8T34rQMSQhz1iVeNnLajpyO2/lNTMY00Xb7bYKVMpQsWRkGE3t60PYyH5EQWSksoK/R6Z4NymP4FMgRWAV8HnR4VbnCwJlkNHnmurdOFuQB0/kzoFCquXPJhaQRnbAlihaBC2GDamhBTnAdiEEQUHnGkKlh0kcIDWZI7UmoaMW52dri4BAXv/ZLwcyQrc1SnCMg==\n" +
"====END LICENSE KEY====";

var decryptedLicenseKeydata = validator.validateLicense(licenseKey);
console.log(JSON.stringify(decryptedLicenseKeydata));