我们提供融合门户系统招投标所需全套资料,包括融合系统介绍PPT、融合门户系统产品解决方案、
融合门户系统产品技术参数,以及对应的标书参考文件,详请联系客服。
const jwt = require('jsonwebtoken');
const SECRET_KEY = 'your_secret_key';
// 创建Token
function createToken(userId) {
return jwt.sign({ userId }, SECRET_KEY, { expiresIn: '1h' });
}
// 验证Token
function verifyToken(token) {
try {
return jwt.verify(token, SECRET_KEY);
} catch (err) {
throw new Error("Invalid token");
}
}
]]>
const crypto = require('crypto');
const ALGORITHM = 'aes-256-cbc';
const KEY = crypto.randomBytes(32);
const IV = crypto.randomBytes(16);
// 加密函数
function encrypt(text) {
let cipher = crypto.createCipheriv(ALGORITHM, KEY, IV);
let encrypted = cipher.update(text);
encrypted = Buffer.concat([encrypted, cipher.final()]);
return { iv: IV.toString('hex'), encryptedData: encrypted.toString('hex') };
}
// 解密函数
function decrypt({ iv, encryptedData }) {
let decipher = crypto.createDecipheriv(ALGORITHM, KEY, Buffer.from(iv, 'hex'));
let decrypted = decipher.update(Buffer.from(encryptedData, 'hex'));
decrypted = Buffer.concat([decrypted, decipher.final()]);
return decrypted.toString();
}
]]>