不使用特殊字符加密CryptoJS [英] Encrypt CryptoJS without special characters

查看:343
本文介绍了不使用特殊字符加密CryptoJS的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 nodejs 我正在尝试为用户生成一个唯一的URL,以符合电子邮件地址.从该URL,用户将能够通过解密密文并将密文数据与数据库进行比较验证电子邮件帐户.我正在使用 CryptoJS 生成网址.

using nodejs I am trying to generate an unique URL for user to conform email address. From that URL user will be able to verify the email account by decrypting the ciphertext and comparing ciphertext data with database . I am using CryptoJS to generate the url.

let url = 'http://localhost:4000/newUser/get/'+ciphertext ;

问题在于密文中包含正斜杠"/",例如:

Problem is that in ciphertext, it contains forward slash " / " eg:

http://localhost:4000/newUser/get/U2FsdGVkX189ZNKKQrYgqU90DDwkl/W3hRTSGO1yvUMaDilPJmz9YYI3d1/E3i9C

路由器正在处理URL上的"/" ,因此路由器正在搜索目录,该目录实际上是密文的一部分.如果有解决方案不包含"/"或密文中的特殊字符,请提供帮助. 提前谢谢.

Router is processing " / " on the URL, thus router is searching for the directory that is actually part of ciphertext. If there is any solution for not including " / " or special characters in ciphertext, please help. Thanks in advance.

推荐答案

您可以轻松地用以下任意文本替换特殊字符:

You can easily replace the special characters with any of text like:

ciphertext.toString().replace('+','xMl3Jk').replace('/','Por21Ld').replace('=','Ml32');

别忘了用特殊字符替换这些字符串

Do not forget to replace these strings back with special characters

dataString.toString().replace('xMl3Jk', '+' ).replace('Por21Ld', '/').replace('Ml32', '=');

希望这将有助于解决您的问题

Hope this will help to solve your problem

这篇关于不使用特殊字符加密CryptoJS的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆