当前位置:网站首页>Implementing cos signature with postman
Implementing cos signature with postman
2022-06-24 01:53:00 【adanhey】
// Get start timestamp
let timestamp =parseInt(new Date().getTime()/1000);
// Get the expiration timestamp
let timestamp2 = timestamp + 3600;
// obtain method
let method = pm.request.method.toString().toLowerCase();
// Get the entire url
let arrUrl = pm.request.url
// adopt url obtain uri
let uuu = arrUrl.toString().split('//')
let start = uuu[1].indexOf("/");
let end = uuu[1].indexOf("?");
if (end==-1){
end = uuu[1].length;
}
let uri = uuu[1].substring(start,end);//stop Omit , Interception from start All characters from beginning to end
// Required parameters for signature
let qAk = pm.globals.get("SecretId");
let SecretKey = pm.globals.get("SecretKey");
// Calculate signature ( Signatures in many projects , The original string also adds the request parameters )
let qSignAlgorithm = 'sha1';
let qSignTime = timestamp + ';' + timestamp2;
let qKeyTime = timestamp + ';' + timestamp2;
let signKey = CryptoJS.HmacSHA1(qKeyTime,SecretKey).toString();
// Step two : constitute FormatString
let formatString = [method, uri, '', '', '',].join('\n');
// Step three : Calculation StringToSign
let stringToSign = ['sha1', qSignTime, CryptoJS.SHA1(formatString).toString(),''].join('\n');
// Step four : Calculation Signature
let Signature = CryptoJS.HmacSHA1(stringToSign, signKey).toString();
// Step five : structure Authorization
let authorization = [
'q-sign-algorithm=' + qSignAlgorithm,
'q-ak=' + qAk,
'q-sign-time=' + qSignTime,
'q-key-time=' + qKeyTime,
'q-header-list='+'',
'q-url-param-list='+'',
'q-signature=' + Signature
].join('&');
pm.environment.set("Authorization", authorization);
边栏推荐
- Learn 30 programming languages in 1 minute
- Tcapulusdb Jun · industry news collection
- A multifunctional SSH Remote Server Management Tool
- [tcapulusdb knowledge base] how does tcapulusdb add a business cluster cluster?
- [planting grass by technology] three big gifts prepared by Tencent cloud for you on the double 11, welcome to touch~
- Gin framework: implementing service end flow limiting Middleware
- Tcapulusdb Jun · industry news collection
- How to create a group on a barcode label
- Software cost evaluation: a method for estimating software scale by fast function point method
- Ppt layout design how to make pages not messy
猜你喜欢

It's too difficult for me. Ali has had 7 rounds of interviews (5 years of experience and won the offer of P7 post)
![[SQL injection 13] referer injection foundation and Practice (based on burpseuite tool and sqli labs less19 target platform)](/img/b5/a8c4bbaf868dd20b7dc9449d2a4378.jpg)
[SQL injection 13] referer injection foundation and Practice (based on burpseuite tool and sqli labs less19 target platform)

Stm32g474 infrared receiving based on irtim peripherals

Review of AI hotspots this week: the Gan compression method consumes less than 1/9 of the computing power, and the open source generator turns your photos into hand drawn photos

I, a 27 year old female programmer, feel that life is meaningless, not counting the accumulation fund deposit of 430000

layer 3 switch
![[SQL injection 12] user agent injection foundation and Practice (based on burpsuite tool and sqli labs LESS18 target machine platform)](/img/c8/f6c2a62b8ab8fa88bd2b3d8f35f592.jpg)
[SQL injection 12] user agent injection foundation and Practice (based on burpsuite tool and sqli labs LESS18 target machine platform)
随机推荐
What is data analysis? Analysis is not storytelling... - Cassie kozyrkov
[technical grass planting] how can this double eleven be cost-effective!
Glusterfs version 4.1 selection and deployment
Devops learning notes (II)
Blog platform was falsely blackmailed and the new hacker organization claimed responsibility for the Israeli attack | November 16 global network security hotspot
Tencent cloud database tdsql elite challenge --q & A
Practical case - Tencent security hosting service MSS helped "zero accident" during the period of digital Guangdong re insurance!
Tcapulusdb Jun · industry news collection
Go language core 36 lectures (go language practice and application VI) -- learning notes
[technical grass planting] the cloud driver takes you straight to the clouds
Line/kotlin jdsl: kotlin DSL for JPA criteria API
6、 Symbols and commands for numerical calculation of variables
[tcapulusdb knowledge base] common problems of tcapulusdb local deployment
SMS marketing is the key to retain customers
How does the education industry realize the TRTC interactive classroom apaas solution under the "double reduction policy"?
How to do AI speech synthesis? How to download the voice of AI speech synthesis?
Moment. JS to UTC format
Detailed explanation of SSH tunnel and stable intranet penetration using autossh
Build and enable all plug-ins of kubesphere high availability cluster
Stm32g474 infrared receiving based on irtim peripherals