Postman achieve Base64 encryption transmission

1.  Click Add -> to add a new collection

2.  adding the collection a new request

 

 

3.  After the top right corner of the eye, the use of environment variables, you can use global variables ( Environment ) You can also use environment variables ( , Ltd. Free Join Environment ), so I personally use environment variables for trouble

4.  Set the name of the environment, in varibles enter the variable name of a variable to be encrypted (made by replacement), the latter two actual value is null, the bottom right click Save update

Update later, you can manage environments View environment variables have been added in, make sure to add success

The  setting request method and url addresses, the content and format; crypto-variable name environment variable replacement fill

6. The  configuration script request before the Pre-Script Requests , (scripting language to JavaScript )

Specific content: Use CryptoJS this library, " var " is JS fixed declarative language of the new variable

① Line: New Tag Card , use CryptoJS library, the original to be encrypted string " 1652423 " is encoded

② line: New variable base64 , use CryptoJS library, the encoded string of base64 types of encryption

③ Line: set an environment variable named: " the cardNumber ", is used to get the first line ② base64 encrypted value

(The variable name and variable names need when setting environment variables the same as before)

7.  Click send to send the request, the anticipated results below. Request field uses Base64 encryption successfully

8.  Click on the top right corner of the eye to see changes in the environment variable, previously empty value where value appeared to be base64 encrypted value coding. After the parameter corresponding to the request is encrypted following the transmission request.

NOTE: Base64 encrypted value receiver can use environment variables may be used or a subset of a set of variables and the variables receiving

  postman not all requested content can be carried out base64 transmits a response result and obtain the correct encrypted

  Base64 encryption operate only on the string, if another format, must first be converted into a string and then treated

Guess you like

Origin www.cnblogs.com/wangx123sec/p/11495023.html