更新记录

1.0.0(2024-08-09) 下载此版本

第一次发布


平台兼容性

uni-app

Vue2 Vue3
?
app-vue app-nvue app-android app-ios app-harmony
? ? ? ? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?
微信小程序 支付宝小程序 百度小程序 字节小程序 QQ小程序 钉钉小程序 快手小程序 飞书小程序 京东小程序
? ? ? ? ? ? ? ? ?
快应用-华为 快应用-联盟
? ?

uni-app x

app-android app-ios
? ?
H5-Safari Android Browser 微信浏览器(Android) QQ浏览器(Android) Chrome IE Edge Firefox PC-Safari
? ? ? ? ? ? ? ? ?

AES128 加解密 jh-cryptojs

如何使用

运算模式:ECB 填充模式:None 密钥长度:128bit 密钥格式:Hex 字符编码:Hex 16 进制 输出格式:Hex

安装 SDK

在插件市场安装

安装依赖

在项目根目录:

yarn add crypto-js

在 script 中引用

import jhcryptojs from '@/js_sdk/jh-aes128'

调用 SDK

    const passKey = 'a6551cbb865756064827539017819606' // 密钥
    const text = '6DB71111111111111111111111122111' // 明文
  const encryptedHex = aesEncrypt(passKey, text); // 加密  FB47E58BFCFB7CA7425B39EE9566C6CA

    const decryptedHex = aesDecrypt(passKey, encryptedHex); // 解密

使用案例

<template>
  <view class="content">
    <image class="logo" src="/static/logo.png"></image>

    <view style="width: 90%"
      >密钥:<input v-model="passkey" style="width: 300"
    /></view>
    <view style="width: 90%"
      >明文:<input v-model="text" style="width: 300"
    /></view>
    <button @click="handleAesEncrypt">加密</button>
    <view v-if="passResult">加密结果: {{ passResult }}</view>
    <button v-if="passResult" @click="handleAesDecrypt">解密</button>
    <view v-if="textResult">解密后的明文: {{ textResult }}</view>
  </view>
</template>

<script>
import {
  aesEncrypt,
  aesDecrypt,
} from "@/js_sdk/jh-aes128";
export default {
  data() {
    return {
      passkey: "a6551cbb865756064827539017819606",
      text: "6db71111111111111111111111111111",
      passResult: "",
      textResult: "",
    };
  },
  onLoad() {},
  methods: {
    handleAesEncrypt() {
      if (this.passkey.length !== 32) {
        uni.showToast({
          title: "密钥长度必须为32位",
          icon: "none",
        });
        this.passResult = "";
        return;
      }
      if (this.text.length !== 32) {
        uni.showToast({
          title: "明文长度必须为32位",
          icon: "none",
        });
        this.passResult = "";
        return;
      }
      const result = aesEncrypt(this.passkey, this.text);
      this.passResult = result;
    },

    handleAesDecrypt() {
      const result = aesDecrypt(this.passkey, this.passResult);
      this.textResult = result;
    },
  },
};
</script>

<style>
.content {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.logo {
  height: 200rpx;
  width: 200rpx;
  margin-top: 200rpx;
  margin-left: auto;
  margin-right: auto;
  margin-bottom: 50rpx;
}

.text-area {
  display: flex;
  justify-content: center;
}

.title {
  font-size: 36rpx;
  color: #8f8f94;
}
</style>

隐私、权限声明

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

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

插件不采集任何数据

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

许可协议

MIT协议

暂无用户评论。

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