# @xushuyi/crypt

> 私有加密解密模块，生产环境为定制配置。

Latest version **1.0.8** (published 2025-06-21) · ISC license · 0 weekly downloads

## Install

```sh
npm install @xushuyi/crypt
pnpm add @xushuyi/crypt
yarn add @xushuyi/crypt
bun add @xushuyi/crypt
```

## Health

**Score 25/100 (F)** — status: maintenance-mode.

Positive: no vulnerabilities.

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

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2025-06-21 |
| First published | 2022-08-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 834.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | xushuyi |
| Maintainers | xushuyi |

## Links

- npm: https://www.npmjs.com/package/@xushuyi/crypt
- Repository: https://gitee.com/xushuyi/crypt_npm
- Homepage: https://gitee.com/xushuyi/crypt_npm#readme
- Issues: https://gitee.com/xushuyi/crypt_npm/issues
- npm.io page: https://npm.io/package/@xushuyi/crypt

## Recent versions

- 1.0.8 (latest) — 2025-06-21
- 1.0.7 — 2023-08-01
- 1.0.6 — 2022-09-02
- 1.0.5 — 2022-09-01
- 1.0.4 — 2022-08-25
- 1.0.3 — 2022-08-25
- 1.0.2 — 2022-08-24
- 1.0.1 — 2022-08-24

## README

# crypt

私有加解密模块，定制模块。

## 配置

### 开发环境下

* AES 加密模式 `CBC`
* 填充模式 `zeropadding`
* 密钥key `1234567890123456`
* 偏移量iv `1234567890abcdef`
* 输出hex

### 生产环境下

* AES 加密模式 `CBC`
* 填充模式 `pkcs5padding`
* 密钥key 从配置文件中读取
* 偏移量iv 从配置文件中读取
* 需要mac address被授权
* 输出hex

## 示例

```
const plainText = "欢迎使用crypt加解密模块。";

console.log('当前加密环境：', crypt.env());
const cipherText = crypt.zmencrypt(plainText);
```

```
const cipherPhone = crypt.zmencrypt('13800138000');
console.log('cipherPhone=', cipherPhone);
```

输出结果： `30bd4f3848b25fae0218a6dcb6ca4a7c`


## 插件提供的方法

* env `插件的环境变量， 非process.env.NODE_ENV变量`
* md5 `MD5方法`
* macaddress `获取服务器mac地址`
* indocker `判断是否在docker环境中`
* zmencrypt `加密方法 aes/cbc/zeropadding/128bit/hex`
* zmdecrypt `解密方法 aes/cbc/zeropadding/128bit/hex`
* starzmdecrypt `解密方法 手机号码星号输出`
* encrypt `加密方法 aes/cbc/pkcs5padding/128bit/hex`
* decrypt `解密方法 aes/cbc/pkcs5padding/128bit/hex`
* stardecrypt `解密方法 手机号码星号输出`

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