# sm4util

> SM4对称加解密

Latest version **1.0.5** (published 2023-07-10) · ISC license · 0 weekly downloads

## Install

```sh
npm install sm4util
pnpm add sm4util
yarn add sm4util
bun add sm4util
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.5 |
| Published | 2023-07-10 |
| First published | 2022-10-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 36.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | XuYijie |
| Maintainers | xuyijie |

## Links

- npm: https://www.npmjs.com/package/sm4util
- Repository: https://github.com/BubblingXuYijie/SM4Util
- Homepage: https://github.com/BubblingXuYijie/SM4Util#readme
- Issues: https://github.com/BubblingXuYijie/SM4Util/issues
- npm.io page: https://npm.io/package/sm4util

## Recent versions

- 1.0.5 (latest) — 2023-07-10
- 1.0.4 — 2023-07-10
- 1.0.3 — 2022-10-25
- 1.0.2 — 2022-10-18

## README

```vue
 * 调用方法：
 * 引入
  import {SM4Util} from "sm4util";
  const sm4 = new SM4Util();

 * 不使用自定义 secretKey，一般用于前端自行加解密,如果是前端加密后端解密，则需要自定义secretKey，前后端一致才能正确解密
  sm4.encryptDefault_ECB('123456');
  sm4.decryptDefault_ECB('123456');
 * secretKey必须为16位字符串，可包含字母数字标点，不能包含非法字符
  sm4.encryptCustom_ECB('123456', 'asdfghjklmnbvcx,');
  sm4.decryptCustom_ECB('123456', 'asdfghjklmnbvcx,');
 
 * CBC 加密模式（更加安全），需要两个密钥
  sm4.encryptDefault_CBC('123456');
  sm4.decryptDefault_CBC('123456');
 * 同样可以自定义 secretKey 和 iv，需要两个密钥前后端都一致，secretKey和iv必须为16位字符串，可包含字母数字标点，不能包含非法字符
  sm4.encryptCustom_CBC('123456', 'asdfghjklmnbvcx,', 'mnbvcxzpoiuytre1');
  sm4.decryptCustom_CBC('123456', 'asdfghjklmnbvcx,', 'mnbvcxzpoiuytre1');
```

---
_Source: https://npm.io/package/sm4util · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
