密码明文加密

This commit is contained in:
binbin_pan 2024-05-24 19:26:57 +08:00
parent 228e983cc5
commit f94744b941
1 changed files with 2 additions and 25 deletions

View File

@ -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>