nx暂不使用加密
This commit is contained in:
parent
5f64adb61d
commit
c6d4e9f551
|
|
@ -5,27 +5,33 @@ import { Notification, MessageBox, Message, Loading } from 'element-ui'
|
||||||
const secretKey = 'CCNXrpassWordKey'
|
const secretKey = 'CCNXrpassWordKey'
|
||||||
|
|
||||||
async function encryptData(data, keyStr) {
|
async function encryptData(data, keyStr) {
|
||||||
const keyUint8 = new TextEncoder().encode(keyStr);
|
try {
|
||||||
const key = await crypto.subtle.importKey(
|
const keyUint8 = new TextEncoder().encode(keyStr);
|
||||||
'raw',
|
const key = await crypto.subtle.importKey(
|
||||||
keyUint8,
|
'raw',
|
||||||
{ name: 'AES-CBC', length: 256 },
|
keyUint8,
|
||||||
false,
|
{ name: 'AES-CBC', length: 256 },
|
||||||
['encrypt']
|
false,
|
||||||
);
|
['encrypt']
|
||||||
|
);
|
||||||
const iv = crypto.getRandomValues(new Uint8Array(16));
|
|
||||||
const cipherTextBuffer = await crypto.subtle.encrypt(
|
const iv = crypto.getRandomValues(new Uint8Array(16));
|
||||||
{ name: 'AES-CBC', iv },
|
const cipherTextBuffer = await crypto.subtle.encrypt(
|
||||||
key,
|
{ name: 'AES-CBC', iv },
|
||||||
new TextEncoder().encode(data)
|
key,
|
||||||
);
|
new TextEncoder().encode(data)
|
||||||
|
);
|
||||||
const combined = new Uint8Array(iv.length + cipherTextBuffer.byteLength);
|
|
||||||
combined.set(iv, 0);
|
const combined = new Uint8Array(iv.length + cipherTextBuffer.byteLength);
|
||||||
combined.set(new Uint8Array(cipherTextBuffer), iv.length);
|
combined.set(iv, 0);
|
||||||
|
combined.set(new Uint8Array(cipherTextBuffer), iv.length);
|
||||||
return btoa(String.fromCharCode.apply(null, combined));
|
|
||||||
|
return btoa(String.fromCharCode.apply(null, combined));
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.log('🚀 ~ 加密失败 ~ error:', error);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const user = {
|
const user = {
|
||||||
|
|
@ -66,7 +72,8 @@ const user = {
|
||||||
// 登录
|
// 登录
|
||||||
async Login({ commit }, userInfo) {
|
async Login({ commit }, userInfo) {
|
||||||
const username = userInfo.username.trim()
|
const username = userInfo.username.trim()
|
||||||
const password = await encryptData(userInfo.password, secretKey);
|
const password = userInfo.password
|
||||||
|
// const password = await encryptData(userInfo.password, secretKey) || ''
|
||||||
const code = userInfo.code
|
const code = userInfo.code
|
||||||
const uuid = userInfo.uuid
|
const uuid = userInfo.uuid
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue