加密解密

2025-07-04 数据加密

# 生成公钥及私钥

加密解密
git bash
openssl genrsa -out private.pem 1024

openssl rsa -in private.pem -pubout -out public.pem
cat private.pem / cat public.pem


# FileReader

pnpm i jsencrypt
import JSEncrypt from 'jsencrypt'

    encryptPassword (password) {
      const encryptor = new JSEncrypt()
      encryptor.setPublicKey(this.publicKey) // 公钥
      return encryptor.encrypt(password)
    },
    decryptPassword (pwd) {
      const decrypt = new JSEncrypt()
      decrypt.setPrivateKey(this.privateKey) // 私钥
      return decrypt.decrypt(pwd)
    },
最后更新于: 2025年7月9日 15:07