Version 0.1.2 - Ajout du systême d'authentification
This commit is contained in:
29
bin/keygen.js
Normal file
29
bin/keygen.js
Normal file
@ -0,0 +1,29 @@
|
||||
const { LogType } = require("loguix")
|
||||
const fs = require("fs")
|
||||
const path = require("path")
|
||||
var CryptoJS = require("crypto-js")
|
||||
const { __glob } = require("./global-variables")
|
||||
const clog = new LogType("KeyGen")
|
||||
const config = require("./config")
|
||||
|
||||
const keypass = config.getFile().ENCRYPTION_KEY
|
||||
|
||||
setup()
|
||||
|
||||
function setup() {
|
||||
if(keypass) {
|
||||
clog.log("Clé de chiffrement trouvé et importé")
|
||||
} else {
|
||||
clog.error("Clé de chiffrement inconnu : Passage en mode par défaut")
|
||||
}
|
||||
}
|
||||
|
||||
module.exports.encrypt = function (text) {
|
||||
let encryptedText = CryptoJS.AES.encrypt(text, keypass).toString();
|
||||
return encryptedText;
|
||||
}
|
||||
|
||||
module.exports.decrypt = function(text) {
|
||||
let decryptedText = CryptoJS.AES.decrypt(text, keypass).toString(CryptoJS.enc.Utf8);
|
||||
return decryptedText;
|
||||
}
|
Reference in New Issue
Block a user