密码明文加密
This commit is contained in:
parent
228e983cc5
commit
f94744b941
|
|
@ -182,6 +182,7 @@
|
|||
|
||||
<script>
|
||||
import { listConfig, getConfig, delConfig, addConfig, updateConfig, refreshCache } from "@/api/system/config";
|
||||
import { decrypt} from '@/utils/jsencrypt'
|
||||
|
||||
export default {
|
||||
name: "Config",
|
||||
|
|
@ -243,11 +244,7 @@ export default {
|
|||
listConfig(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
|
||||
response.rows.forEach(row => {
|
||||
if (row.configKey == 'sys.user.initPassword') {
|
||||
this.decryptData(row.configValue, this.secretKey).then(data => {
|
||||
row.configValue = data;
|
||||
}).catch(err => {
|
||||
console.log('🚀 ~ decryptData ~ err:', err);
|
||||
});
|
||||
row.configValue = decrypt(row.configValue)
|
||||
}
|
||||
});
|
||||
this.configList = response.rows;
|
||||
|
|
@ -348,26 +345,6 @@ export default {
|
|||
this.$modal.msgSuccess("刷新成功");
|
||||
});
|
||||
},
|
||||
async decryptData(encryptedData, keyStr) {
|
||||
const keyUint8 = new TextEncoder().encode(keyStr);
|
||||
const encryptedBytes = Uint8Array.from(atob(encryptedData), c => c.charCodeAt(0));
|
||||
|
||||
const key = await crypto.subtle.importKey(
|
||||
'raw',
|
||||
keyUint8,
|
||||
{ name: 'AES-CBC', length: 256 }, // 假设后端使用了CBC模式,需要调整为实际使用的模式
|
||||
false,
|
||||
['decrypt']
|
||||
);
|
||||
|
||||
const decryptedData = await crypto.subtle.decrypt(
|
||||
{ name: 'AES-CBC', iv: new Uint8Array(16) }, // 实际使用时需要正确的IV,这里仅为示例
|
||||
key,
|
||||
encryptedBytes
|
||||
);
|
||||
|
||||
return new TextDecoder().decode(decryptedData);
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
Loading…
Reference in New Issue