加密没有特殊字符的 CryptoJS [英] Encrypt CryptoJS without special characters

查看:73
本文介绍了加密没有特殊字符的 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.

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

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

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

http://localhost:4000/newUser/get/U2FsdGVkX189ZNKKQ​​rYgqU90DDwkl/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天全站免登陆