登录密码基于加密算法加密

This commit is contained in:
floraachy 2025-02-14 11:12:53 +08:00
parent 39dc6389ab
commit 13f48e5148
2 changed files with 48 additions and 2 deletions

25
dist/index.js vendored
View File

@ -34712,6 +34712,29 @@ const upload_artifact = async () => {
const new_domain = domain.endsWith('/') ? domain.slice(0, -1) : domain;
console.log("new_domain: ", new_domain)
// -------------------- 将登录密码基于平台加密算法加密----------------------------
function aesEncrypt(plainText, keyStr, ivStr) {
// 将字符串密钥和IV转换为16字节的Buffer
const key = Buffer.from(keyStr.slice(0, 16), 'utf8');
const iv = Buffer.from(ivStr.slice(0, 16), 'utf8');
// 创建并设置AES-CBC加密器
const cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
// 加密数据并添加PKCS7填充
let encryptedData = cipher.update(plainText, 'utf8', 'base64');
encryptedData += cipher.final('base64');
return encryptedData;
}
const key = '59c96c3572ab8cc1'; // 密钥
const iv = '59c96c3572ab8cc1'; // 初始化向量
// 加密
const pwd = aesEncrypt(password, key, iv);
console.log("加密后的密码: ", pwd);
try {
// -------------------- 登录获取用户cookies----------------------------
@ -34719,7 +34742,7 @@ const upload_artifact = async () => {
"headers": {
"content-type": "application/json",
},
"body": `{\"login\":\"${username}\",\"password\":\"${password}\",\"autologin\":0}`,
"body": `{\"login\":\"${username}\",\"password\":\"${pwd}\",\"autologin\":0}`,
"method": "POST",
"mode": "cors",
"credentials": "include"

View File

@ -38,6 +38,29 @@ const upload_artifact = async () => {
const new_domain = domain.endsWith('/') ? domain.slice(0, -1) : domain;
console.log("new_domain: ", new_domain)
// -------------------- 将登录密码基于平台加密算法加密----------------------------
function aesEncrypt(plainText, keyStr, ivStr) {
// 将字符串密钥和IV转换为16字节的Buffer
const key = Buffer.from(keyStr.slice(0, 16), 'utf8');
const iv = Buffer.from(ivStr.slice(0, 16), 'utf8');
// 创建并设置AES-CBC加密器
const cipher = crypto.createCipheriv('aes-128-cbc', key, iv);
// 加密数据并添加PKCS7填充
let encryptedData = cipher.update(plainText, 'utf8', 'base64');
encryptedData += cipher.final('base64');
return encryptedData;
}
const key = '59c96c3572ab8cc1'; // 密钥
const iv = '59c96c3572ab8cc1'; // 初始化向量
// 加密
const pwd = aesEncrypt(password, key, iv);
console.log("加密后的密码: ", pwd);
try {
// -------------------- 登录获取用户cookies----------------------------
@ -45,7 +68,7 @@ const upload_artifact = async () => {
"headers": {
"content-type": "application/json",
},
"body": `{\"login\":\"${username}\",\"password\":\"${password}\",\"autologin\":0}`,
"body": `{\"login\":\"${username}\",\"password\":\"${pwd}\",\"autologin\":0}`,
"method": "POST",
"mode": "cors",
"credentials": "include"