登录密码基于加密算法加密
This commit is contained in:
parent
39dc6389ab
commit
13f48e5148
|
@ -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"
|
||||
|
|
25
src/index.js
25
src/index.js
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue