smt-md5
解释: 在小程序开发中,没有window的概念,导致市面上很多绑定DOM或者BOM的三方库无法使用,@smt-lib/md5是官方提供的md5和base64算法库。
小程序种使用三方npm包方法,见npm使用说明
npm install @smt-lib/md5
方法 encodeHex
|类型 |必填 | 默认值 |说明|
|---- | ---- | ---- | ----|----|
|String | 是 | | 要转换的字符串 |
代码示例
import {encodeHex} from '@smt-lib/md5';
const string = 'abcdefghigklmn';
const md5edString = encodeHex(string);
方法 encodeBase64
|类型 |必填 | 默认值 |说明|
|---- | ---- | ---- | ----|----|
|String | 是 | | 要转换的字符串 |
代码示例
import {encodeBase64} from '@smt-lib/md5';
const string = 'abcdefghigklmn';
const base64edString = encodeBase64(string);