前端SM4/SM2/SM3加解密

import sm from "sm-crypto";
// 注意加这个包起来 key 和 iv
const text = new TextEncoder();

console.log(
  123,
  sm.sm4.decrypt(
    "0932d0497791aa94ba067fb0256cb4c5c3c6619b87b893e3720c105ad1178816",
    text.encode("kvc7rczjgbt0hl8d"),
    {
      mode: "ECB",
      iv: text.encode("ucti2325e9srkrqa"),
    }
  )
);

 uniapp中安卓不兼容处理

npm i text-decoding

import { TextEncoder } from 'text-decoding'

const utf8encoder = new TextEncoder();

 

posted @ 2024-03-28 10:30  xuanPhoto  阅读(645)  评论(0编辑  收藏  举报