博客
关于我
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/

    你可能感兴趣的文章
    org.springframework.beans.factory.BeanDefinitionStoreException
    查看>>
    org.springframework.boot.context.properties.ConfigurationBeanFactoryMetadata
    查看>>
    org.springframework.boot:spring boot maven plugin丢失---SpringCloud Alibaba_若依微服务框架改造_--工作笔记012
    查看>>
    SQL-CLR 类型映射 (LINQ to SQL)
    查看>>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    查看>>
    org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
    查看>>
    org.springframework.web.multipart.MaxUploadSizeExceededException: Maximum upload size exceeded
    查看>>
    org.tinygroup.serviceprocessor-服务处理器
    查看>>
    org/eclipse/jetty/server/Connector : Unsupported major.minor version 52.0
    查看>>
    org/hibernate/validator/internal/engine
    查看>>
    Orleans框架------基于Actor模型生成分布式Id
    查看>>
    SQL-36 创建一个actor_name表,将actor表中的所有first_name以及last_name导入改表。
    查看>>
    ORM sqlachemy学习
    查看>>
    Ormlite数据库
    查看>>
    orm总结
    查看>>
    ORM框架 和 面向对象编程
    查看>>
    OS X Yosemite中VMware Fusion实验环境的虚拟机文件位置备忘
    查看>>
    os.environ 没有设置环境变量
    查看>>
    os.path.join、dirname、splitext、split、makedirs、getcwd、listdir、sep等的用法
    查看>>
    os.removexattr 的 Python 文档——‘*‘(星号)参数是什么意思?
    查看>>