更新记录

1.0.1(2025-06-23)

新增DES、MD5、hmacSha256、sha256等加密方式

1.0.0(2025-06-21)

初始版本


平台兼容性

uni-app(4.26)

Vue2 Vue3 Chrome Safari app-vue app-nvue Android iOS 鸿蒙
- - -
微信小程序 支付宝小程序 抖音小程序 百度小程序 快手小程序 京东小程序 鸿蒙元服务 QQ小程序 飞书小程序 快应用-华为 快应用-联盟
- - - - - - - - - - -

uni-app x(4.26)

Chrome Safari Android iOS 鸿蒙 微信小程序
- - - -

yzc-encry RSA加密、AES加密、base64加密、DES加密、MD5加密、HMAC-SHA-256加密、SHA-256加密,支持安卓、iOS(需要打自定义基座)

导入

import { EncryUtils } from '@/uni_modules/yzc-encry';

RSA加解密

// 设置钥匙对别名 必须
EncryUtils.setKeyAlias('xxxxx')
// 导出公钥
const publicKey = EncryUtils.exportPublicKey()
console.log(publicKey)
// rsa加密 返回值为string或者null 如果是uniappx使用string接收可以使用?? 操作符处理为null的情况
const rsa_encryptedData = EncryUtils.rsa_encrypt("your data", publicKey)
console.log("rsa_encrypt", rsa_encryptedData)
// rsa解密 返回值为string或者null
const rsa_decryptedData = EncryUtils.rsa_decrypt(rsa_encryptedData)
console.log("rsa_decrypt", rsa_decryptedData)

AES-256-CBC 加解密

// 密钥必须为16/24/32字节
const aes_key = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
// AES 加密 返回值为string或者null
const aes_encryptedData = EncryUtils.aes256cbc_encrypt(aes_key, "your data")
console.log('aes_encrypt', aes_encryptedData)
// AES 解密 返回值为string或者null
const aes_decryptedData = EncryUtils.aes256cbc_decrypt(aes_key, aes_encryptedData)
console.log('aes_decrypt', aes_decryptedData)

base64加解密

// base64加密 返回值为string或者null
const base64_encryptedData = EncryUtils.base64_encrypt("your data")
console.log('base64_encrypt', base64_encryptedData)
// base64解密 返回值为string或者null
const base64_decryptedData = EncryUtils.base64_decrypt(base64_encryptedData)
console.log('base64_decrypt', base64_decryptedData)

DES加解密

// 密钥必须为8字节
const aes_key = "xxxxxxxx"
// 初始化向量8字节
const des_iv = "xxxxxxxx"
// DES加密 返回值为string或者null
const des_encryptedData = EncryUtils.des_encrypt(key, iv, "your data")
console.log('des_encrypt', des_encryptedData)
// DES解密 返回值为string或者null
const des_decryptedData = EncryUtils.des_decrypt(key, iv, des_encryptedData)
console.log('des_decrypt', des_decryptedData)

MD5加密

// MD5加密 返回值为string
const md5_encrypt = EncryUtils.md5(plainText)
console.log("md5_encrypt: ", md5_encrypt)

HMAC-SHA-256加密

// hmacSha256_encrypted加密 返回值为string或者null
const hmacSha256_encrypted = EncryUtils.hmacSha256(key, plainText)
console.log("hmacSha256_encrypted: ", hmacSha256_encrypted)

SHA-256加密

// sha256_encrypted加密 返回值为string或者null
const sha256_encrypted = EncryUtils.sha256(plainText)
console.log("sha256_encrypted: ", sha256_encrypted)

隐私、权限声明

1. 本插件需要申请的系统权限列表:

2. 本插件采集的数据、发送的服务器地址、以及数据用途说明:

插件不采集任何数据

3. 本插件是否包含广告,如包含需详细说明广告表达方式、展示频率:

暂无用户评论。

使用中有什么不明白的地方,就向插件作者提问吧~ 我要提问