@perfylee/crypto
Version:
encryption module used in project
41 lines (30 loc) • 800 B
Markdown
对常用加解密方法的二次封装,方便在项目中使用
```
//npm
npm install @perfylee/crypto
//yarn
yarn add @perfylee/crypto
```
MD5加密,返回结果小写
```typescript
import {md5} from '@perfylee/crypto'
const encrypted = md5('input')
```
TripleDES加解密,密钥为长度24的字符串的base64编码,加密返回结果小写
```typescript
import {tripleDES} from '@perfylee/crypto'
const encrypted = tripleDES.encrypt('input','密钥')
const decrypted = tripleDES.decrypt(encrypted,'密钥')
```
Base64编码和解码
```typescript
import {base64} from '@perfylee/crypto'
const output = base64.parse('input')
const input = base64.stringify(output)
```