Encrypt CryptoJS without special characters

前端 未结 3 1205
滥情空心
滥情空心 2021-01-15 12:32

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 th

3条回答
  •  情深已故
    2021-01-15 13:00

    IMHO, for @JaiKumarRajput's answer,

    He encoded the string with,

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

    Now, I have no idea how xMl3Jk, Por21Ld, Ml32 works. So, i also don't know if it can mess my string somehow.
    Plus, As I have to perform this on decoding as well. So, Why wont I use something like this (What already exists),

    encodeURIComponent(ciphertext.toString('base64'))
    

    I know it still introduces % char. But as its getting used in URL. In which its a escape char.

    How does it matter more than doing something that can mess my code up ??

    NOTE: I used it and had no issue, It doesn't mean I either had found any issue with the top one. That didn't feel neat. Its only my humble opinion, So if u don't like it? Ignore it.

提交回复
热议问题