如何用角度加密和解密URL [英] how to encrypt and decrypt URL in angular

查看:49
本文介绍了如何用角度加密和解密URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,这里有两个模块(Staff,Agent).我单击代理模块列表",URL显示代理/列表"并更新一个代理,URL传递的id对应于id.但是我想要加密的数据通过更新并在URL中列出.那么如何在Angular 6中传递加密(用户不理解)的值

In my project, two modules here(Staff, Agent ). I click Agent module list and URL shows Agent /list and update one Agent , URL passing id corresponding id . But i want encrypted data passing update and list in URL. So how to pass encrypted (user not understanding) values in Angular 6

return this.repository.postData('api/agent/list', requestObj);

推荐答案

您可以使用 atob btoa 函数来实现.这是一个示例:

You can achieve this by using atob and btoa functions. Here is an example:

console.log(btoa("some data")); // this will encode the data 
console.log(atob("some data")); // this will decode the data 

所以您需要这样实现:

return this.repository.postData('api/agent/list', btoa(requestObj));

这篇关于如何用角度加密和解密URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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