使用Postman编码变量

哈莎·W

是否可以使用Postman本身对变量进行编码?

例如:

{
  "UserName": "[email protected]",
  "Password": "test@123",
  "ConfirmPassword": "test@123",
  "Role": "SuperAdmin"
}

是否可以使用Postman本身对密码字段进行编码并将其发送到服务器?我将上面的JSON数据传递到body / header部分中。

有可能在邮递员内部做这样的事情吗

base64UrlEncode(Password) 
保利布

可以使用Postman预请求脚本Postman环境变量

第一步是设置要加密的变量。

接下来,编写一个脚本。邮递员具有内置的CryptoJs,可用于编码字符串。这是Base64编码字符串的示例脚本,并将环境变量设置为编码后的值:

var plainText = pm.environment.get('plainTextString');
var encrypted = CryptoJS.enc.Base64.stringify(plainText);

console.log(`Encrypted value: ${encrypted}`) //if you want to see the value in the console
pm.environment.set("myEncryptedRequestVariable", encrypted);

最后,使用以下语法在请求正文(或标头)中使用加密的变量:

{{myEncryptedRequestVariable}} 

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章