v.1.0.0. initial push of license-lib
This commit is contained in:
14
server/keygen.js
Normal file
14
server/keygen.js
Normal 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 };
|
Reference in New Issue
Block a user