您的位置:首页 > 科技 > IT业 > sm2和md5前端对密码加密的方法

sm2和md5前端对密码加密的方法

2024/10/7 2:29:10 来源:https://blog.csdn.net/wtd183833501176/article/details/141195959  浏览:    关键词:sm2和md5前端对密码加密的方法

1. 需求:对前端的明文变为加密后的传给后端

2.方法:sm2或者md5

md5:其中reqObj.password就是输入的密码

import { Md5 } from 'ts-md5';const md5:any = new Md5()md5.appendAsciiStr(reqObj.password);const npassword = md5.end()reqObj.password = npassword;

sm2:后端会给你公钥和私钥,将私钥的数字复制到publicKey的赋值数据中

import { sm2 } from 'sm-crypto-v2';
const publicKey = `后端给你的私钥`;const npassword = sm2.doEncrypt(reqObj.password, publicKey, 1);reqObj.password = npassword;

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com