v.1.0.0. initial push of license-lib

This commit is contained in:
2025-03-19 09:37:30 -05:00
commit b22a1c973c
20 changed files with 433 additions and 0 deletions

14
server/keygen.js Normal file
View File

@@ -0,0 +1,14 @@
// server/keygen.js
const crypto = require('crypto');
const { encrypt } = require('./utils/crypto');
const generateLicenseKey = (userId) => {
const rawKey = crypto.randomBytes(32).toString('hex');
const payload = { userId, rawKey, issued: Date.now() };
const encryptedKey = encrypt(payload);
return encryptedKey;
};
const hashLicenseKey = (key) => crypto.createHash('sha256').update(key).digest('hex');
module.exports = { generateLicenseKey, hashLicenseKey };