const crypto = require('crypto');
const license_key = "key.ing!123456789";
let mt = '2021/11/1', mt1 = getCode(mt);
console.log(mt + " : " + mt1 + " : " + aesEncrypt(mt1));
function getCode(date) {
let mt = new Date(date).getTime();
return mt.toString().substring(0, 3) + '2' + mt.toString().substring(3);
}
function aesEncrypt(data) {
const cipher = crypto.createCipher('aes192', license_key);
var crypted = cipher.update(data, 'utf8', 'hex');
crypted += cipher.final('hex');
return crypted;
}
function aesDecrypt(encrypted) {
const decipher = crypto.createDecipher('aes192', license_key);
var decrypted = decipher.update(encrypted, 'hex', 'utf8');
decrypted += decipher.final('utf8');
return decrypted;
}