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

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

问题描述

在我的项目中,这里有两个模块(员工、代理).我点击 Agent 模块列表,URL 显示 Agent/list 并更新一个 Agent,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);

推荐答案

您可以通过使用 atobbtoa 函数来实现这一点.下面是一个例子:

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天全站免登陆