博客
关于我
uni-app中添加AES加密教程
阅读量:164 次
发布时间:2019-02-28

本文共 702 字,大约阅读时间需要 2 分钟。

在Uniapp项目中集成JSEncrypt进行加密处理,可以按照以下步骤进行操作:

  • 安装依赖
    通过Yarn或npm安装JSEncrypt包:
  • yarn add jsencrypt --type=dep  或者  npm install jsencrypt --save-dev
    1. 解压并替换文件
      安装完成后,进入项目的node_modules文件夹,找到jsencrypt包:
    2. cd node_modules  cd jsencrypt

      jsencrypt.js文件从bin文件夹中解压出来,替换原有文件。

      1. 引入依赖
        在项目文件中使用以下代码引入JSEncrypt:
      2. import JSEncrypt from 'jsencrypt'
        1. 实现加密解密功能
          在方法中使用JSEncrypt进行加密和解密操作:
        2. methods: {  encryptedData(publicKey, data) {    const encryptor = new JSEncrypt()    encryptor.setPublicKey(publicKey)    return encryptor.encrypt(data)  },  decryptData(privateKey, secretWord) {    const decrypt = new JSEncrypt()    decrypt.setPrivateKey(privateKey)    return decrypt.decrypt(secretWord)  }}

          注意:确保在项目中正确导入并设置公钥和私钥,JSEncrypt库能够正常运行。

    转载地址:http://xxec.baihongyu.com/

    你可能感兴趣的文章
    Node.js安装与配置指南:轻松启航您的JavaScript服务器之旅
    查看>>
    Node.js的循环与异步问题
    查看>>
    nodejs libararies
    查看>>
    nodejs 运行CMD命令
    查看>>
    nodejs-mime类型
    查看>>
    nodejs中Express 路由统一设置缓存的小技巧
    查看>>
    NodeJs学习笔记001--npm换源
    查看>>
    Node入门之创建第一个HelloNode
    查看>>
    NOIp2005 过河
    查看>>
    NOPI读取Excel
    查看>>
    NotImplementedError: Cannot copy out of meta tensor; no data! Please use torch.nn.Module.to_empty()
    查看>>
    npm run build 失败Compiler server unexpectedly exited with code: null and signal: SIGBUS
    查看>>
    npm WARN deprecated core-js@2.6.12 core-js@<3.3 is no longer maintained and not recommended for usa
    查看>>
    npm切换到淘宝源
    查看>>
    npm前端包管理工具简介---npm工作笔记001
    查看>>
    npm和yarn清理缓存命令
    查看>>
    npm和yarn的使用对比
    查看>>
    npm报错unable to access ‘https://github.com/sohee-lee7/Squire.git/‘
    查看>>
    npm的问题:config global `--global`, `--local` are deprecated. Use `--location=global` instead 的解决办法
    查看>>
    NPOI之Excel——合并单元格、设置样式、输入公式
    查看>>