# ctjt-safe-util

> safe-util to used

Latest version **1.1.0** (published 2023-12-07) · ISC license · 0 weekly downloads

## Install

```sh
npm install ctjt-safe-util
pnpm add ctjt-safe-util
yarn add ctjt-safe-util
bun add ctjt-safe-util
```

## 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.1.0 |
| Published | 2023-12-07 |
| First published | 2023-12-07 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 12 |
| Unpacked size | 29.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | zhengXiaoHuan |
| Maintainers | xiaozheng-tutu |

## Links

- npm: https://www.npmjs.com/package/ctjt-safe-util
- npm.io page: https://npm.io/package/ctjt-safe-util

## Dependencies (12)

- [md5](https://npm.io/package/md5.md) ^2.3.0
- [axios](https://npm.io/package/axios.md) ^1.6.2
- [js-md5](https://npm.io/package/js-md5.md) ^0.8.3
- [webpack](https://npm.io/package/webpack.md) ^5.89.0
- [babel-core](https://npm.io/package/babel-core.md) ^6.26.3
- [babel-jest](https://npm.io/package/babel-jest.md) ^29.7.0
- [webpack-cli](https://npm.io/package/webpack-cli.md) ^5.1.4
- [babel-loader](https://npm.io/package/babel-loader.md) ^9.1.3
- [ctjt-safe-util](https://npm.io/package/ctjt-safe-util.md) ^1.0.0
- [babel-preset-env](https://npm.io/package/babel-preset-env.md) ^1.7.0
- [clean-webpack-plugin](https://npm.io/package/clean-webpack-plugin.md) ^4.0.0
- [babel-plugin-add-module-exports](https://npm.io/package/babel-plugin-add-module-exports.md) ^1.0.4

## Recent versions

- 1.1.0 (latest) — 2023-12-07
- 1.0.0 — 2023-12-07

## README

## 前端防篡改安全包

### 1、安装

npm install signatureUtil

### 2、使用

const { signatureGenerate, signatureCheck }  = require('signatureUtil')

import { signatureGenerate, signatureCheck } from "signatureGenerate"

### 3、例子（使用场景）

```javascript
//  请求拦截携带签名

service.interceptors.request.use(

  (config) => {

​     const {signature, timestamp} = signatureGenerate(config)

​     // console.log(signature);

​     // console.log(timestamp);

​     // 分别将签名、密钥、时间戳 至请求头 

​     if(signature) config.headers["signature"] = signature

​     if(timestamp) config.headers["timestamp"] = timestamp

​    return config

  },

  (err) => {

​    console.log(err)

  }

)
```

```javascript
// 响应拦截校验签名
service.interceptors.response.use(
  (response) => {
  	return signatureCheck(response)
  },
  (err) => {
    console.error('服务调用出错', err)
    return { code: 500, message: '服务出错' }
  }
)
```

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