Encrypt CryptoJS without special characters

前端 未结 3 1171
滥情空心
滥情空心 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

    However, .replace() will only replace first occurrence.

    To be more precise, you can use something like this :

    // Original Text
    var ciphertext = 'asda+dasd+asdas/asdasd/sadasdasd/dadasd=adsasda=dasd=';
    
    // Replaced Text
    var dataString = ciphertext.replace(/\+/g,'p1L2u3S').replace(/\//g,'s1L2a3S4h').replace(/=/g,'e1Q2u3A4l');
    console.log(dataString);
    
    // Back to Original Text
    ciphertext = dataString.replace(/p1L2u3S/g, '+' ).replace(/s1L2a3S4h/g, '/').replace(/e1Q2u3A4l/g, '=');
    console.log(ciphertext);

提交回复
热议问题