Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sha256 #16

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PRIVATE_KEY=1230A6701B12cc39
ALPHA_KEYS=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ coverage/
# Deployed apps should consider commenting this line out:
# see https://npmjs.org/doc/faq.html#Should-I-check-my-node_modules-folder-into-git
node_modules/
.env
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"nuxt.isNuxtApp": false
}
5 changes: 3 additions & 2 deletions lib/License.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
'use strict'

const md5 = require('md5')
const crypt = require('./encrypt-decrypt')
const errors = require('./errors')
const os = require('./supported')
const { createHash } = require('node:crypto')

/**
* @class License
Expand Down Expand Up @@ -138,7 +138,8 @@ const generateHash = (info, prodCode, appVersion, osType) =>
const uniqueOSID = generateOSHash(osType)
//
const userInfoStr = infoClean + prodCode + appVr + uniqueOSID
return (md5(userInfoStr)).toUpperCase()
// return (md5(userInfoStr)).toUpperCase()
return (createHash('SHA256').update(userInfoStr).digest('hex')).toUpperCase()
}

/**
Expand Down
8 changes: 4 additions & 4 deletions lib/encrypt-decrypt.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ const errors = require('./errors')
* @param {string} privKey private key
* @returns {string} encrypted string
*/
const encryptString = (str, privKey = '1230A6701B12cc39') =>
const encryptString = (str, privKey = process.env.PRIVATE_KEY) =>
{
//
if (!str) throw (errors('ENCRYPT_ERROR'))
if (privKey === '') throw (errors('ENCRYPT_ERROR'))
//
const alfaKeys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
const alfaKeys = process.env.ALPHA_KEYS
const alfaArray = alfaKeys.split('')
let encryptedString = ''
let z = 0
Expand All @@ -38,11 +38,11 @@ const encryptString = (str, privKey = '1230A6701B12cc39') =>
* @param {string} privKey private key
* @returns {string} decrypted string
*/
const decryptString = (str, privKey = '1230A6701B12cc39') =>
const decryptString = (str, privKey = process.env.PRIVATE_KEY) =>
{
//
if (!str) throw errors('DECRYPT_ERROR')
const alfaKeys = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'
const alfaKeys = process.env.ALPHA_KEYS
const alfaArray = alfaKeys.split('')
let decryptedString = ''
let z = 0
Expand Down
1 change: 1 addition & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
//
var validateLicense = require('./validateLicense')
var createLicense = require('./createLicense')
require('dotenv').config()
//
module.exports = { validateLicense, createLicense }
Loading