Angular6引入Md5,使用md5加密

1.安装依赖

npm install ts-md5 --save

2.页面引用

import { Md5 } from "ts-md5/dist/md5";

//let md5Value = Md5.hashStr("value")
ngOnInit() {
    console.log(Md5.hashStr('加密'));
    //十六进制字符串,32位小写,常用
    //56563edf23b9d717dc63981b8836fc60
    console.log(Md5.hashStr('加密', true))//32 位二补码有符号整数,大小4字节
    // [-549562794, 400013603, 462971868, 1627141768]
    console.log(Md5.hashAsciiStr('加密'))//十六进制字符串
    //2228f0e9007f05342a4be3f5377d8a29
    console.log(Md5.hashAsciiStr('加密', true))//32 位二补码有符号整数,大小4字节
    //[-370137054, 872775424, -169653462, 696941879]
}    

猜你喜欢

转载自blog.csdn.net/come0across/article/details/88534741