{"id":2256,"date":"2023-05-31T16:36:35","date_gmt":"2023-05-31T08:36:35","guid":{"rendered":"https:\/\/cowmanchiang.me\/wp\/?p=2256"},"modified":"2023-10-31T15:41:34","modified_gmt":"2023-10-31T07:41:34","slug":"aes-decrypt-in-postman","status":"publish","type":"post","link":"https:\/\/cowmanchiang.me\/wp\/?p=2256","title":{"rendered":"AES decrypt in postman"},"content":{"rendered":"<p>sample code:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"\">var CryptoJS = require(&quot;crypto-js&quot;); \nlet secretKey = &#039;yourSecretKey&#039;; \n\nfunction decrypt(aesStr, key) { \n    return CryptoJS.AES.decrypt( \n        aesStr, \n        CryptoJS.enc.Utf8.parse(padding(key)), \n        { \n            mode: CryptoJS.mode.ECB, \n            padding: CryptoJS.pad.Pkcs7 \n        } \n    ).toString(CryptoJS.enc.Utf8) \n} \n\nfunction padding(key) { \n    return key.padEnd(32, &#039;\\0&#039;); \n} \n\n\/\/decrypt(&quot;encryptedData&quot;, secretKey)<\/pre>\n<p>Here we choose AES-256 to encrypt \/ decrypt the secure information. When using AES, the length of the secretKey is important. The length of secretKey in AES-128 is 16 bits, and in AES-256 is 32 bits.<\/p>\n<p>And in our case, the length of secretKey is no enough. So we will use the function padding to fill in the missing length.<\/p>\n<p>source: <a href=\"https:\/\/blog.csdn.net\/na_tion\/article\/details\/105428572\">CSDN: AES\u89e3\u5bc6\uff0ckey\u957f\u5ea6\u4e0d\u591f16\u5904\u7406<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>sample code: var CryptoJS = require(&quot;crypto-js&quot;); let secretKey = &#039;yourSecretKey&#039;; function decrypt(aesStr, key) { return CryptoJS.AES.decrypt( aesStr, CryptoJS.enc.Utf8.parse(padding(key)), { mode: CryptoJS.mode.ECB, padding: CryptoJS.pad.Pkcs7 } ).toString(CryptoJS.enc.Utf8) } function padding(key) { return key.padEnd(32, &#039;\\0&#039;); } \/\/decrypt(&quot;encryptedData&quot;, secretKey) Here we choose AES-256 to &hellip; <a href=\"https:\/\/cowmanchiang.me\/wp\/?p=2256\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[52,107],"tags":[],"class_list":["post-2256","post","type-post","status-publish","format-standard","hentry","category-javascript","category-postman"],"_links":{"self":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2256","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2256"}],"version-history":[{"count":3,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2256\/revisions"}],"predecessor-version":[{"id":2259,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=\/wp\/v2\/posts\/2256\/revisions\/2259"}],"wp:attachment":[{"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2256"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2256"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cowmanchiang.me\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2256"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}