encrypt.js 458 Bytes
import JSEncrypt from 'jsencrypt'
import { getPublicKey } from '@/api/auth'

/**
 * RSA加密
 * @param password
 * @returns {Promise<{param: PromiseLike<ArrayBuffer>}|*>}
 */
export async function encryptedData(password) {
  let publicKey = ''
  const res = await getPublicKey()
  publicKey = res.value
  if (publicKey == '') {
    return password
  }
  const encrypt = new JSEncrypt()
  encrypt.setPublicKey(publicKey)
  return encrypt.encrypt(password)
}