SecretInput.vue 856 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <template>
  2. <el-input
  3. v-model="password"
  4. type="password"
  5. show-password
  6. v-bind="$attrs"
  7. @blur="encryptPassword"
  8. />
  9. </template>
  10. <script setup lang="ts">
  11. import { ref } from 'vue'
  12. const password = ref('')
  13. const modelValue = defineModel<{ rsa_aesKey: string; cipher_text: string }>()
  14. // 加密处理
  15. const encryptPassword = () => {
  16. if (!password.value?.trim()) {
  17. return
  18. }
  19. /// 获取AES秘钥
  20. // @ts-ignore
  21. const aesKey = window?.BpmTools?.$generateAESKey()
  22. // 将AES秘钥加密
  23. // @ts-ignore
  24. const rsaAesKey = window?.BpmTools?.$encryptAESKey(aesKey)
  25. // 进行AES算法加密密码
  26. // @ts-ignore
  27. const newPwd = window?.BpmTools?.$encryptDataWithAES(aesKey, password.value)
  28. // rsaAesKey和newPwd构建db_password字段
  29. modelValue.value = {
  30. rsa_aesKey: rsaAesKey,
  31. cipher_text: newPwd
  32. }
  33. }
  34. </script>
  35. <style scoped></style>