调整登录页面,rsa登录修改为固定公钥,新增邮箱登录页面

This commit is contained in:
2023-09-22 01:08:45 +08:00
parent 5ed643de18
commit f474b4439f
34 changed files with 1232 additions and 270 deletions
@@ -1,5 +1,5 @@
import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'
import jsrsasign from 'jsrsasign'
import { KEYUTIL, KJUR } from 'jsrsasign'
// 密钥对生成 http://web.chacuo.net/netrsakeypair
const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALj0zjON+EVdBsnMcR4Uj+jOYgp5ZipftQZ1utW8KvVioz+RSaotF1JHt59q9SC/mZcWWpbpcEqQ3WyyyCC33msCAwEAAQ=='
@@ -7,6 +7,17 @@ const publicKey = 'MFwwDQYJKoZIhvcNAQEBBQADSwAwSAJBALj0zjON+EVdBsnMcR4Uj+jOYgp5Z
const privateKey =
'MIIBVAIBADANBgkqhkiG9w0BAQEFAASCAT4wggE6AgEAAkEAuPTOM434RV0GycxxHhSP6M5iCnlmKl+1BnW61bwq9WKjP5FJqi0XUke3n2r1IL+ZlxZalulwSpDdbLLIILfeawIDAQABAkB5PYAtq1KjpWddwPYlkbUEFsWNuCaQgExZ/7KJiN9gGjo/UfUZ3W39Orb8PITIYf1NbasReqgddAcsfJNyoDWBAiEA7K89DyTmbjNSmekdD3rejRDdMzzXYtcbo69ZjHoowMUCIQDIDN8eg6PcWk4kiRcRYcNEfriUJR7Fg07ellSPv821bwIhAJA5TEyxIJUgQwI0cZfgOELfdtrlBR5ek6IPlNKsEa89AiBbMVroexPQWC41A3VLjChKagXUKpO7b98dIqRLnyCz6wIgP3qpvnO4IOxY7f5XarfCVyIHZJAMt/R1f16P5OkKv+A='
const publicPem = `
-----BEGIN PUBLIC KEY-----
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAo7yRx+lfHxy/c7lZFtZn
A3GBeQ+9nxBuOcSz/I8l0dP5JZsWVE+jMtmoxnFrTgCsnGuDHMNpSlexUc3IVcsp
bC4tSWh/r4Gy9KsIw0tIY0pulKsN/VhV//7dajMV/Dg+Rd5bwGGjWrlWOp2EPVYB
HI66uZ3PpEQe3FbEdaLkJRTENbywgGcGo1tqUpqY5BDGAu9IiXwZe4hdM2uniFS2
RKcYDovCiJE1lA7yyx9HEUd9PhYMhPMLvIIdPWW2Gqxsi3IZgG25hER0+o3zICgq
G/2VbodBM65JTLBY+KnY6H3o80b0v2qwOB7TktVtWQR6Lz8Ud+qrlgeAzvZb5Fmp
DQIDAQAB
-----END PUBLIC KEY-----`
// 加密
export function encrypt(txt) {
const encryptor = new JSEncrypt()
@@ -21,7 +32,9 @@ export function decrypt(txt) {
return encryptor.decrypt(txt) // 对数据进行解密
}
export const encryptByPublicKey = (txt, publicKey) => {
const pubKey = jsrsasign.KEYUTIL.getKey(publicKey)
return jsrsasign.KJUR.crypto.Cipher.encrypt(txt, pubKey)
export const encryptByPublicKey = (txt: string, publicKey: string = publicPem) => {
const pubKey = KEYUTIL.getKey(publicKey)
// const ciphertext = KJUR.crypto.Cipher.encrypt(txt, pubKey, 'RSA')
const ciphertext = pubKey.encrypt(txt)
return btoa(atob(ciphertext).padStart(128, '\0'))
}
+11
View File
@@ -0,0 +1,11 @@
import { ComponentCustomProperties, ComponentInternalInstance, getCurrentInstance } from 'vue'
interface UseCurrentInstance {
globalProperties: ComponentCustomProperties & Record<string, any>
}
export default function useCurrentInstance(): UseCurrentInstance {
const { appContext } = getCurrentInstance() as ComponentInternalInstance
const globalProperties = appContext.config.globalProperties
return {
globalProperties
}
}