<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>API on seth-shi</title><link>https://sethix.com/tags/api/</link><description>Recent content in API on seth-shi</description><generator>Hugo -- gohugo.io</generator><language>en</language><lastBuildDate>Wed, 07 Sep 2022 16:52:05 +0800</lastBuildDate><atom:link href="https://sethix.com/tags/api/index.xml" rel="self" type="application/rss+xml"/><item><title>Application of AES Encryption Algorithm</title><link>https://sethix.com/posts/2022090716/</link><pubDate>Wed, 07 Sep 2022 16:52:05 +0800</pubDate><guid>https://sethix.com/posts/2022090716/</guid><description>Recently, I&amp;rsquo;ve been working on integrating third-party advertising bidding services. Most advertising platforms with bidding capabilities encrypt their bid prices using the AES algorithm.
When integrating with third parties, challenges arise due to varying encryption modes and the lack of SDKs (some only provide Java client code examples). Here are some practical approaches:
Use third-party validation tools like https://tool.lmeee.com/jiami/aes for cross-verification Analyze Java code to identify critical encryption parameters: Encryption Mode (ECB, CBC, CFB, OFB) Padding Method (pkcs5padding, pkcs7padding, zeropadding) Key Length (128-bit/8-char key, 192-bit/12-char key, 256-bit/16-char key) IV (Initialization Vector - some require random values, others use fixed values) Base64UrlSafe Encoding requirement for ciphertext Practical Observations: ECB Dominance: Many platforms use ECB mode for simplicity despite security risks, as it requires only a key (no IV).</description></item><item><title>Cross-Service Data Verification Using AES Algorithm</title><link>https://sethix.com/posts/2021051112/</link><pubDate>Tue, 11 May 2021 12:41:39 +0800</pubDate><guid>https://sethix.com/posts/2021051112/</guid><description>Recently while working on an advertising service that requires cross-application data transmission between backend services (PHP + Go), we chose symmetric encryption for implementation.
Common Pitfalls Key Length Errors may occur if using a 32-bit key (since documentation states valid lengths are 16, 24, 32)
AES-128: Requires 16-byte key
AES-192: Requires 24-byte key
AES-256: Requires 32-byte key
Always match key length to the selected algorithm.
Padding Algorithm Easily overlooked in PHP due to simple usage: $text = &amp;#34;String to encrypt&amp;#34;; // Key length must match algorithm requirements $key = &amp;#34;2bfbd593bb32b2b9&amp;#34;; // AES-128-ECB depends on chosen algorithm openssl_encrypt($text, &amp;#39;AES-128-ECB&amp;#39;, $key); The above produces base64-encoded output by default.</description></item><item><title>Using Middleware for Request Caching in Slim4</title><link>https://sethix.com/posts/2019112812/</link><pubDate>Thu, 28 Nov 2019 12:39:39 +0800</pubDate><guid>https://sethix.com/posts/2019112812/</guid><description>When developing web pages or API interfaces, we often encounter the following scenario:
A request is processed by querying the database and returning transformed data Some pages/interfaces with infrequent data changes (e.g. homepage) may experience performance issues under high traffic Solution: Cache processed content in storage like Redis before returning the response Subsequent requests first check the cache - return immediately if valid If cache expires, repeat steps [3-4] Here&amp;rsquo;s an implementation in Slim4 framework:</description></item><item><title>RESTful Routing URL Naming Conventions</title><link>https://sethix.com/posts/2018040521/</link><pubDate>Thu, 05 Apr 2018 21:11:41 +0800</pubDate><guid>https://sethix.com/posts/2018040521/</guid><description>A previous blog briefly introduced Using RESTful in Laravel This article explains various RESTful-style route writing conventions. While not necessarily authoritative, these patterns are semantically meaningful in practice. Base Routing Typically grouped with a common prefix: Always follows API + version format /api/v1 Basic Parameters Pagination parameters using QueryString: limit page Example: /url?limit=10&amp;amp;page=1 Multi-parameter sorting: Example: /url?desc=created_at,id&amp;amp;asc=grade,updated_at Fundamental Routes List categories: method: GET /categories Create category: method: POST /categories Delete category: method: DELETE /categories/{category} Get single category: method: GET /categories/{category} Update category: method: PUT /categories/{category} Intermediate Routes Get articles under category: method: GET /categories/{category}/articles Get articles with tag: method: GET /tags/{tag}/articles Batch delete articles (avoid when possible): method: DELETE /articles/batch?</description></item><item><title>Insights on Developing RESTful APIs with Laravel</title><link>https://sethix.com/posts/2018030122/</link><pubDate>Thu, 01 Mar 2018 22:06:16 +0800</pubDate><guid>https://sethix.com/posts/2018030122/</guid><description>Here are some insights I’ve gained while working with Laravel to develop RESTful APIs.
Getting Started API Authentication: For public APIs, consider OAuth2.0; for private/internal APIs, token-based authentication (e.g., JWT) is often sufficient. Versioning: Include an API version in routes for future scalability: Route::prefix(&amp;#39;v1&amp;#39;)-&amp;gt;group(function () { // Routes here }); CORS Handling: Use the barryvdh/laravel-cors package for seamless cross-origin requests. Sample API Endpoint
Example Code Authentication Use jwt-auth for JWT-based authentication.</description></item></channel></rss>