Node.js 如何在angular 8中通过url传递加密数据

Node.js 如何在angular 8中通过url传递加密数据,node.js,typescript,angular8,cryptojs,Node.js,Typescript,Angular8,Cryptojs,尝试在angular 8中通过url传递加密数据,但无法工作,因为包含该url的加密数据未正确打开。因此,如何在angular 8中通过url传递加密数据。如果知道,请帮助任何人 我们能在没有特殊记录的情况下记录数据吗?可能吗 示例:U2FsdGVkX18+ijuMYTf/b2jVWBRoAGWMJ+AnFlwodjE=此数据具有/so url将不会打开。如何解决这个问题 像这样的描述: let encriptionData = CryptoJS.AES.encrypt("

尝试在angular 8中通过url传递加密数据,但无法工作,因为包含该url的加密数据未正确打开。因此,如何在angular 8中通过url传递加密数据。如果知道,请帮助任何人

我们能在没有特殊记录的情况下记录数据吗?可能吗

示例:U2FsdGVkX18+ijuMYTf/b2jVWBRoAGWMJ+AnFlwodjE=此数据具有/so url将不会打开。如何解决这个问题

像这样的描述:

     let encriptionData =  CryptoJS.AES.encrypt("test@gmail.com", 'secret key 123').toString();
我正在传递这样的加密数据

var url = "http://localhost:4200/content/" + encriptionData;
路由器.module.ts:

 { path : 'content/:id' , component : contentComponent },
content.component.ts:

 //url is http://localhost:4200/content/U2FsdGVkX18+ijuMYTf/b2jVWBRoAGWMJ+AnFlwodjE=

 this._Activatedroute.paramMap.subscribe(params => { 

    var bytes  = CryptoJS.AES.decrypt(params.get('id'), 'secret key 123');
    this.decryptedMailid = bytes.toString(CryptoJS.enc.Utf8);  
    console.log(this.decryptedMailid); 

  });

您可以对加密字符串进行编码,然后在解密之前对其进行解码

 let encryptedData =  encodeURIComponent(CryptoJS.AES.encrypt("test@gmail.com", 'secret key 123').toString());
现在,代替
http://localhost:4200/content/U2FsdGVkX18+ijuMYTf/b2jVWBRoAGWMJ+AnFlwodjE=
,您的url将是
http://localhost:4200/content/U2FsdGVkX18%2BijuMYTf%2Fb2jVWBRoAGWMJ%2BAnFlwodjE%3D

在content.component.ts中,执行以下操作以反转操作:

this._Activatedroute.paramMap.subscribe(params => { 

    var bytes  = CryptoJS.AES.decrypt(params.get('id'), 'secret key 123');
    this.decryptedMailid = decodeURIComponent(bytes.toString(CryptoJS.enc.Utf8));  
    console.log(this.decryptedMailid); 

});

您可以对加密字符串进行编码,然后在解密之前对其进行解码

 let encryptedData =  encodeURIComponent(CryptoJS.AES.encrypt("test@gmail.com", 'secret key 123').toString());
现在,代替
http://localhost:4200/content/U2FsdGVkX18+ijuMYTf/b2jVWBRoAGWMJ+AnFlwodjE=
,您的url将是
http://localhost:4200/content/U2FsdGVkX18%2BijuMYTf%2Fb2jVWBRoAGWMJ%2BAnFlwodjE%3D

在content.component.ts中,执行以下操作以反转操作:

this._Activatedroute.paramMap.subscribe(params => { 

    var bytes  = CryptoJS.AES.decrypt(params.get('id'), 'secret key 123');
    this.decryptedMailid = decodeURIComponent(bytes.toString(CryptoJS.enc.Utf8));  
    console.log(this.decryptedMailid); 

});

如果可能,我建议您在更改url之前对加密数据进行url编码path@ShamPooSham:如何在没有特殊字符的情况下对数据进行加密?您可以在加密的数据库上使用
encodeURIComponent
data@ShamPooSham:请..你能编辑我的代码吗?怎么做?@Shamposham:如果我使用encodeURIComponent,如何对其进行解码以进行描述?如果可能,我建议您在更改url之前对加密数据进行url编码path@ShamPooSham:如何在没有特殊字符的情况下对数据进行加密?您可以在加密的数据库上使用
encodeURIComponent
data@ShamPooSham:请..你能编辑我的代码吗?怎么做?@Shamposham:如果我使用encodeURIComponent,如何解码它来描述?