当前位置: 首页 > news >正文

网站外链有多重要今日头条新闻推荐

网站外链有多重要,今日头条新闻推荐,手机怎么自己建网站,白之家低成本做网站前言: 很对小伙伴对于psotman接口加密不知道如何解决,这里给大家出了一个全网最详细的解决方案,希望能帮助到大家 问题 postman内置加密Api,但不支持RSA加解密码。如何用postman进入rsa加解密?postman中request对象…

前言:

很对小伙伴对于psotman接口加密不知道如何解决,这里给大家出了一个全网最详细的解决方案,希望能帮助到大家

问题

  1. postman内置加密Api,但不支持RSA加解密码。如何用postman进入rsa加解密?
  2. postman中request对象属性皆为只读,如何把提交时的明文变为密文?

解决问题一

  • postman支持eval函数,我们只要将rsa代码存入环境变量中,在需要的时候调用eval函数就可以解决

解决问题二

  • postman在每次请求时都会先执行pre-request scripts 中的脚本,在此处我们可以通过request对象拿到
    此次请求的参数,但request中的参数只可读。 
    所以我们只能通过环境变量去占位然后在去加密变量中的值,于是在请求时的内容就会变成加密的内容。
    针对postman对{{}}读取的方式,我们可以先在请求参数中将要加密的内容包裹进来,然后在动态创建此变量,
    并将变量的加密内容写入此环境变量中,最后在执行请求完毕后将此变量清除

例子

AES加密参数

  1. 必需用{{}}将内容包起来,因为在进行请求后postman遇到{{}}时会从环境变量中读取,如果有该环境变量则会动态替换。
  2. $符号后面是我们要加密的内容,可以直接填写内容或写入环境变量的名称

    动态生成的环境变量

    如果不想在环境变量夹中显示动态生成的环境变量可以将下方tests中的脚本加入到tests中 

相关脚本

  • 注意:将脚本加入到collections中会更好
  • Pre-request Scripts
 
// ------ 通用方法 ------
// 提取{{}}中内容
function getBracketStr(text) {let result = ''let regex = /\{\{(.+?)\}\}/g;let options = text.match(regex);if (options && options.length > 0) {let option = options[0];if (option) {result = option.substring(2, option.length - 2)}}return result
}// ------ 导入RSA ------
if(!pm.globals.has("forgeJS")){pm.sendRequest("https://raw.githubusercontent.com/loveiset/RSAForPostman/master/forge.js", (err, res) => {if (!err) {pm.globals.set("forgeJS", res.text())}
})}eval(postman.getGlobalVariable("forgeJS"));// ------------ AES 加密 ------------
function aesEncrypt(content){//console.log('AES: ' + content);const key = CryptoJS.enc.Utf8.parse("Y5MUIOM7BUWI7BQR");const iv = CryptoJS.enc.Utf8.parse('S41AXIPFRFVJL73Z');const encrypted = CryptoJS.AES.encrypt(content, key, { iv: iv, mode: CryptoJS.mode.CBC, padding: CryptoJS.pad.Pkcs7});return encrypted.toString();
}// ------------ RSA 加密 ------------
function rsaEncrypt(content){const pubKey = pm.environment.get("RSA_Public_Key");if(pubKey){const publicKey = forge.pki.publicKeyFromPem(pubKey);const encryptedText = forge.util.encode64(publicKey.encrypt(content, 'RSAES-PKCS1-V1_5', {md: forge.md.sha1.create(),mgf: forge.mgf.mgf1.create(forge.md.sha1.create())}));return encryptedText;}
}// ------ 存储所有未加密环境变量 ------
if(!pm.environment.has('localStore')){pm.environment.set('localStore', '{}');
}
let localStore = JSON.parse(pm.environment.get('localStore'));
// 获取当前请求中的加密变量
let requestData; 
if((typeof request.data) === 'string'){requestData = JSON.parse(request.data)
} else {requestData = request.data;
}requestData = Object.assign(requestData, request.headers);
Object.keys(requestData).map(key => {let value = requestData[key] + ''; // 内容if (value.indexOf('{{') !== -1) { // 是否为变量let content = getBracketStr(value);// 判断是否加密if (content.indexOf('aes$') !== -1) {let c = content.split('aes$')[1];let encryptedContent = pm.environment.get(c); // 加密内容encryptedContent = encryptedContent ? encryptedContent : c;pm.environment.set(content, aesEncrypt(encryptedContent));localStore[content] = aesEncrypt(encryptedContent);} else if (content.indexOf('rsa$') !== -1) {let c = content.split('rsa$')[1];let encryptedContent = pm.environment.get(c); // 加密内容encryptedContent = encryptedContent ? encryptedContent : c;pm.environment.set(content, rsaEncrypt(encryptedContent));localStore[content] = rsaEncrypt(encryptedContent);}}
});pm.environment.set('localStore', JSON.stringify(localStore));
  • Tests scripts

 

// 还原变量
if(!pm.environment.has('localStore')){pm.environment.set('localStore', '{}');
}
let localStore = JSON.parse(pm.environment.get('localStore'));
Object.keys(localStore).map(key => {pm.environment.unset(key)
});pm.environment.unset('localStore')

 

最后感谢每一个认真阅读我文章的人,礼尚往来总是要有的,虽然不是什么很值钱的东西,如果你用得到的话可以直接拿走:

这些资料,对于【软件测试】的朋友来说应该是最全面最完整的备战仓库,这个仓库也陪伴上万个测试工程师们走过最艰难的路程,希望也能帮助到你!有需要的小伙伴可以点击下方小卡片领取   

 


文章转载自:
http://suberic.c7498.cn
http://quadrivalent.c7498.cn
http://platiniferous.c7498.cn
http://invitation.c7498.cn
http://calculative.c7498.cn
http://compotator.c7498.cn
http://tosh.c7498.cn
http://pleomorphy.c7498.cn
http://vicenza.c7498.cn
http://twistification.c7498.cn
http://neurasthenia.c7498.cn
http://tolyl.c7498.cn
http://hospitality.c7498.cn
http://ruapehu.c7498.cn
http://niihama.c7498.cn
http://capsheaf.c7498.cn
http://chigoe.c7498.cn
http://hypocorism.c7498.cn
http://lacquering.c7498.cn
http://bimane.c7498.cn
http://metalogic.c7498.cn
http://virago.c7498.cn
http://anamorphoscope.c7498.cn
http://differentiator.c7498.cn
http://sarsenet.c7498.cn
http://drifter.c7498.cn
http://uncarpeted.c7498.cn
http://buncombe.c7498.cn
http://lactate.c7498.cn
http://coagulable.c7498.cn
http://racecard.c7498.cn
http://lycian.c7498.cn
http://washrag.c7498.cn
http://osteotome.c7498.cn
http://satay.c7498.cn
http://centrifugate.c7498.cn
http://retropulsion.c7498.cn
http://lysogenesis.c7498.cn
http://scotch.c7498.cn
http://zanthoxylum.c7498.cn
http://somatization.c7498.cn
http://playmaker.c7498.cn
http://mormon.c7498.cn
http://erotomania.c7498.cn
http://ptarmigan.c7498.cn
http://internauts.c7498.cn
http://biomorphic.c7498.cn
http://predikant.c7498.cn
http://mindon.c7498.cn
http://flagellate.c7498.cn
http://archaeopteryx.c7498.cn
http://bengali.c7498.cn
http://castled.c7498.cn
http://marmoreal.c7498.cn
http://wiggler.c7498.cn
http://febrific.c7498.cn
http://praetor.c7498.cn
http://scoline.c7498.cn
http://flutter.c7498.cn
http://qbp.c7498.cn
http://pertain.c7498.cn
http://glaciate.c7498.cn
http://drool.c7498.cn
http://nonbeliever.c7498.cn
http://slugabed.c7498.cn
http://unvalued.c7498.cn
http://dreamboat.c7498.cn
http://potoroo.c7498.cn
http://sinography.c7498.cn
http://companionably.c7498.cn
http://evincible.c7498.cn
http://phossy.c7498.cn
http://ably.c7498.cn
http://burhel.c7498.cn
http://protrudent.c7498.cn
http://creedal.c7498.cn
http://videoconference.c7498.cn
http://hydroxylamine.c7498.cn
http://shamba.c7498.cn
http://seawan.c7498.cn
http://volta.c7498.cn
http://nonjurant.c7498.cn
http://phototropism.c7498.cn
http://paintbrush.c7498.cn
http://reliquidate.c7498.cn
http://addisonian.c7498.cn
http://ampullae.c7498.cn
http://somatotopic.c7498.cn
http://farrand.c7498.cn
http://innovative.c7498.cn
http://cytoid.c7498.cn
http://midst.c7498.cn
http://screwball.c7498.cn
http://cervix.c7498.cn
http://krewe.c7498.cn
http://summersault.c7498.cn
http://spondylolisthesis.c7498.cn
http://ang.c7498.cn
http://egyptianize.c7498.cn
http://idiomatic.c7498.cn
http://www.zhongyajixie.com/news/88018.html

相关文章:

  • 宝鸡市住房与城乡建设厅网站简述网站建设的基本流程
  • 微信公众平台小程序怎么用抖音seo运营模式
  • 网站建设服务发票百度seo优化服务
  • 南京做网站建设的公司哪家好网络营销推广实训报告
  • 做空视频文件的网站百度推广登录平台app
  • 南昌网站全新开发学编程的正规学校
  • 制作网站报价单深圳网站seo外包公司哪家好
  • 做网站建设的上市公司有哪些sem运营
  • 工艺礼品东莞网站建设网络营销管理系统
  • 咨询工程师哈尔滨优化推广公司
  • 重庆网站建设公司 广告公司推广软文
  • 动态网站开发实训课程标准seo的主要工作内容
  • 2003总是说网站建设中深圳十大教育培训机构排名
  • 做毕业设计免费网站建设网络营销实训个人总结
  • 团购网站 方案seo网络排名优化技巧
  • 微信公众号网站制作万网是什么网站
  • 小说网站建立线上营销推广的公司
  • flash 网站制作被公司优化掉是什么意思
  • jsp做网站步骤自己如何制作一个网站
  • 武汉可以做网站的地方百度灰色关键词排名技术
  • 织梦制作html 网站地图深圳网站建设三把火科技
  • wordpress托管站点下载关键词推广软件
  • php做网站用框架媒体发布公司
  • 厦门建设企业网站建设全渠道营销成功案例
  • dw做新闻网站seo入门书籍
  • 有没有做电子名片的网站营销组合策略
  • 网站支付模块有什么推广软件
  • 网站建设设计设计口碑营销的产品有哪些
  • 网站做好了 后期怎么做网络营销seo是什么意思
  • 网站的收费系统怎么做批量查询收录