<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Shashi Raj on Medium]]></title>
        <description><![CDATA[Stories by Shashi Raj on Medium]]></description>
        <link>https://medium.com/@shashirajraja?source=rss-2339b0a1ffc9------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*Cx9_1CPHijslTq32</url>
            <title>Stories by Shashi Raj on Medium</title>
            <link>https://medium.com/@shashirajraja?source=rss-2339b0a1ffc9------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 20:59:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shashirajraja/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Retrying Payment Requests Sounds Easy Until Customers Get Charged Twice]]></title>
            <link>https://medium.com/@shashirajraja/retrying-payment-requests-sounds-easy-until-customers-get-charged-twice-876b9fdfc042?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/876b9fdfc042</guid>
            <category><![CDATA[retry]]></category>
            <category><![CDATA[financial-advice]]></category>
            <category><![CDATA[payment-gateway]]></category>
            <category><![CDATA[payments]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Wed, 30 Sep 2026 17:32:23 GMT</pubDate>
            <atom:updated>2026-09-30T17:32:23.772Z</atom:updated>
            <content:encoded><![CDATA[<p>Most software engineers are taught a simple rule:</p><blockquote><em>If a request fails, retry it.</em></blockquote><blockquote>For most systems, that’s good advice.</blockquote><blockquote>For payment systems, it can become a very expensive mistake.</blockquote><p>A poorly designed retry mechanism can lead to duplicate authorizations, duplicate captures, refund investigations, customer complaints, and hours of reconciliation work.</p><p>The scary part is that retries usually happen with good intentions. The system is trying to recover from an error. The problem is that in payments, you are often dealing with uncertainty rather than failure.</p><h3>The Most Dangerous Payment Response</h3><p>Let’s look at three scenarios.</p><p><strong>Scenario 1</strong></p><pre>Request Sent<br>↓<br>Declined Response Received</pre><p>The outcome is clear. The payment failed.</p><p><strong>Scenario 2</strong></p><pre>Request Sent<br>↓<br>Approved Response Received</pre><p>Again, the outcome is clear. The payment succeeded.</p><p><strong>Scenario 3</strong></p><pre>Request Sent<br>↓<br>No Response Received</pre><p>Now things become interesting.</p><blockquote>Did the processor receive the request?</blockquote><blockquote>Was the card approved?</blockquote><blockquote>Did the response get lost?</blockquote><blockquote>Did the gateway timeout?</blockquote><blockquote>Nobody knows.</blockquote><blockquote>And that’s where payment problems begin.</blockquote><h3>How Customers Get Charged Twice</h3><p>Imagine you’re buying something online.</p><p>You click <strong>Pay Now</strong>.</p><p>Your application sends an authorization request.</p><p>The issuer approves it.</p><p>Unfortunately, before the approval reaches your application, a network timeout occurs.</p><p>Your application sees:</p><pre>No Response</pre><p>The payment platform sees:</p><pre>Approved</pre><p>Your retry logic kicks in and sends the same payment request again.</p><p>The issuer receives another authorization request and approves it again.</p><p>The customer now sees two authorizations for a single purchase.</p><p>From the application’s perspective, everything worked exactly as designed.</p><p>From the customer’s perspective, they’ve just been charged twice.</p><h3>Why Payment Retries Are Different</h3><p>Most distributed systems care about whether a request was completed.</p><p>Payment systems care about whether a financial action was completed exactly once.</p><p>That’s a huge difference.</p><p>Sending the same request twice may be harmless when updating a profile picture.</p><p>Sending the same request twice can be a disaster when moving money.</p><p>A payment system must answer an additional question:</p><blockquote><em>If this request is retried, how do we prevent processing it twice?</em></blockquote><h3>Enter Idempotency</h3><p>One of the most important concepts in payment engineering is <strong>idempotency</strong>.</p><p>It sounds complicated but the goal is simple:</p><blockquote><em>Process a business operation once, even if the same request is received multiple times.</em></blockquote><p>Imagine a client sends:</p><pre>Idempotency-Key: payment-123</pre><p>The payment processor stores the result.</p><p>If the exact same operation is submitted again with the same idempotency key, the processor doesn’t create a new payment.</p><p>Instead, it returns the original result.</p><pre>First Request<br>→ Payment Processed</pre><pre>Retry Request<br>→ Original Result Returned</pre><p>No duplicate charge.</p><p>No duplicate authorization.</p><p>No customer complaint.</p><h3>Not Every Failure Should Be Retried</h3><p>One mistake many teams make is treating every payment failure the same way.</p><p>In reality, some failures are retryable and others are not.</p><h3>Usually Safe to Retry</h3><pre>Network Timeout<br>Transient Connectivity Failure<br>Gateway Timeout<br>Temporary Service Unavailable</pre><h3>Requires Investigation</h3><pre>Unknown Transaction State<br>No Response Received<br>Connection Lost After Submission</pre><h3>Usually Not Worth Retrying</h3><pre>Insufficient Funds<br>Expired Card<br>Invalid Card Number<br>Do Not Honor<br>Lost/Stolen Card</pre><p>Retrying a declined card every few seconds rarely changes the result.</p><p>Retrying an unknown transaction can create duplicates if handled incorrectly.</p><p>Understanding the difference is crucial.</p><h3>The Hidden Cost of Duplicate Transactions</h3><p>Most people think duplicate transactions only create customer frustration.</p><p>The impact is much broader.</p><p>Duplicate payments often result in:</p><ul><li>Increased support tickets</li><li>Lengthy investigations</li><li>Refund processing</li><li>Financial reconciliation effort</li><li>Chargeback disputes</li><li>Reduced customer trust</li></ul><p>A single duplicate transaction can cost more in operational effort than the original payment value itself.</p><h3>Why Payment Engineers Love Correlation IDs</h3><p>Modern payment platforms assign unique identifiers to every request.</p><p>These may be called:</p><ul><li>Correlation IDs</li><li>Transaction IDs</li><li>Request IDs</li><li>Trace IDs</li></ul><p>When something goes wrong, these identifiers help teams answer critical questions:</p><pre>Did the request reach the gateway?<br>Did the processor receive it?<br>Was an authorization created?<br>Was a retry submitted?</pre><p>Without proper tracing, payment investigations become guesswork.</p><h3>Building Safer Payment Retries</h3><p>Mature payment platforms typically combine multiple protections:</p><ol><li><strong>Idempotency Keys </strong>: Prevent duplicate processing.</li><li><strong>Correlation IDs:</strong> Track requests across systems.</li><li><strong>Retry Policies:</strong> Control when and how retries occur.</li><li><strong>Duplicate Detection:</strong> Identify repeated transaction attempts.</li><li><strong>Reconciliation Processes:</strong> Catch issues that escape earlier controls.</li></ol><p>None of these mechanisms are perfect on their own.</p><p>Together, they dramatically reduce the risk of duplicate charges.</p><h3>The Lesson Every Payment Engineer Learns</h3><p>In most systems, retries improve reliability.</p><p>In payment systems, retries improve reliability only when duplicate protection exists.</p><p>That’s why payment engineering isn’t just about moving money.</p><p>It’s about dealing with uncertainty safely.</p><p>Because the most dangerous payment is often not the failed one.</p><p>It’s the one that might have succeeded when nobody was looking.</p><h3>Final Thoughts</h3><p>The next time you see a timeout in a payment flow, resist the urge to immediately say:</p><p><em>“Let’s just retry it.”</em></p><blockquote>A timeout does not always mean failure.</blockquote><blockquote>A lost response does not always mean the payment wasn’t approved.</blockquote><blockquote>And a duplicate request does not always behave the way you expect.</blockquote><blockquote>The best payment systems aren’t the ones that retry the fastest.</blockquote><blockquote>They’re the ones that ensure a customer is charged exactly once, no matter how many retries occur behind the scenes. ``</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=876b9fdfc042" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[HMAC vs OAuth vs API Keys vs Bearer Tokens]]></title>
            <link>https://medium.com/@shashirajraja/hmac-vs-oauth-vs-api-keys-vs-bearer-tokens-b332627d3da6?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/b332627d3da6</guid>
            <category><![CDATA[oauth]]></category>
            <category><![CDATA[keys]]></category>
            <category><![CDATA[bearer-token]]></category>
            <category><![CDATA[hmac]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Wed, 30 Sep 2026 17:01:54 GMT</pubDate>
            <atom:updated>2026-09-30T17:01:54.232Z</atom:updated>
            <content:encoded><![CDATA[<h3>Choosing the Right API Authentication Strategy</h3><p><em>If you’ve ever integrated with a payment gateway, banking API, webhook provider, or enterprise platform, you’ve probably come across a confusing mix of authentication options: API Keys, Bearer Tokens, OAuth, HMAC, and Mutual TLS (mTLS).</em></p><p><strong>A common question is: </strong><em>Why are some financial systems still using HMAC when OAuth exists?</em></p><p><strong>The answer is simple:</strong> These mechanisms solve different problems.</p><p>Let’s break them down in plain English.</p><h3>The Authentication Landscape</h3><p>When one system talks to another, there are three fundamental questions:</p><ol><li>Who is making this request?</li><li>Is this request allowed?</li><li>Has the request been modified along the way?</li></ol><p>Different authentication methods answer different parts of those questions.</p><h3>1. API Keys</h3><p>The simplest approach.</p><p>A client sends a key with every request.</p><pre>X-API-Key: abc123</pre><p>The server checks whether the key is valid.</p><p>If yes: ✅ Request accepted</p><p>If no: ❌ Request rejected</p><h3><strong>Pros</strong></h3><ul><li>Very easy to implement</li><li>Easy to test</li><li>Minimal infrastructure</li></ul><h3>Cons</h3><ul><li>No protection against payload tampering</li><li>If the key leaks, anyone can use it</li><li>No proof that a request actually came from a trusted system</li></ul><h3>Best Use Cases</h3><ul><li>Internal tools</li><li>Low-risk APIs</li><li>Development environments</li></ul><h3>2. Bearer Tokens</h3><p>You’ve probably seen this:</p><pre>Authorization: Bearer eyJhbGciOi...</pre><p>The keyword is “Bearer”.</p><p>It literally means: <strong><em>Whoever possesses this token can use it.</em></strong></p><blockquote>If someone has the token, they can access the API until the token expires.</blockquote><h3>Pros</h3><ul><li>Widely supported</li><li>Easy to integrate</li><li>Works well with user authentication</li></ul><h3>Cons</h3><ul><li>Token theft is a risk</li><li>Requires token management</li><li>Requires token expiration and refresh handling</li></ul><h3>Best Use Cases</h3><ul><li>Mobile applications</li><li>Web applications</li><li>User-facing APIs</li></ul><h3>3. OAuth 2.0</h3><p>OAuth is often mistaken as an authentication mechanism. It’s actually more about authorization.</p><p>OAuth answers: <strong><em>What is this application allowed to do?</em></strong></p><blockquote>Imagine logging into a third-party website using Google.</blockquote><p>Google asks:</p><pre>Allow this application to:<br>✓ View profile<br>✓ Read email</pre><p><em>The user approves.</em></p><p><em>The application receives an access token.</em></p><p><em>That token represents</em> <em>permissions granted by the user.</em></p><h3>Pros</h3><ul><li>Fine-grained permissions</li><li>User delegation support</li><li>Industry standard</li><li>Strong ecosystem</li></ul><h3>Cons</h3><ul><li>More complex than API Keys</li><li>Token lifecycle management required</li><li>Can be overkill for simple system-to-system communication</li></ul><h3>Best Use Cases</h3><ul><li>Google APIs</li><li>Microsoft Graph</li><li>GitHub Apps</li><li>Open Banking APIs</li><li>Any API acting on behalf of users</li></ul><h3>4. HMAC Authentication</h3><p>Now we get to the interesting one.</p><p>HMAC stands for: <strong>Hash-based Message Authentication Code</strong></p><blockquote>Instead of sending a secret key directly, both systems share a secret.</blockquote><blockquote>The sender generates a signature.</blockquote><pre>Signature =<br>HMAC_SHA256(<br>    secretKey,<br>    requestData<br>)</pre><blockquote>The receiver performs the same calculation.</blockquote><p>If both values match:</p><p>✅ The sender knows the secret</p><p>✅ The request wasn’t changed</p><h3>Why HMAC Is So Popular in Payments</h3><p>Payment providers care deeply about two things:</p><ol><li>Authenticity</li><li>Integrity</li></ol><p>They need to know:</p><ul><li>Who sent the request?</li><li>Has any field been modified?</li></ul><p>Consider this payload:</p><pre>{<br>  &quot;amount&quot;: 100<br>}</pre><p>Imagine an attacker changes it to:</p><pre>{<br>  &quot;amount&quot;: 10000<br>}</pre><p>The signature immediately becomes invalid.</p><p>The server rejects the request.</p><p>This is one reason HMAC remains extremely popular in payment systems and webhook integrations.</p><h3>What Gets Signed?</h3><p>This is where integrations often get tricky. Different providers sign different parts of the request.</p><p><strong>Option 1</strong>: Request Body Only</p><pre>HMAC(secret, body)</pre><p><strong>Option 2: </strong>Timestamp + Body</p><pre>HMAC(secret, timestamp + body)</pre><p><strong>Option 3: </strong>Method + Path + Body</p><pre>HMAC(secret,<br>      POST<br>      + /payments<br>      + body)</pre><p><strong>Option 4</strong>: Canonical Request</p><pre>Method<br>URI<br>Query Parameters<br>Headers<br>Payload</pre><p>This is similar to what AWS Signature V4 uses.</p><p>The more components included, the harder it becomes for attackers to manipulate requests.</p><p><strong>What Problem Does HMAC Solve?</strong></p><blockquote>HMAC answers two critical questions:</blockquote><p><strong>Question 1 </strong>: Did the request come from someone who knows the shared secret? ✅ Yes</p><p><strong>Question 2 : </strong>Has the message been changed since it was signed? ✅ Yes</p><p>This combination makes HMAC powerful.</p><h3>Why Not Just Use HTTPS?</h3><p>A very common question.</p><blockquote>HTTPS protects communication while data travels over the network.</blockquote><blockquote>HMAC protects the message itself.</blockquote><p>Think of it like this:</p><pre>HTTPS = Secure Delivery Truck</pre><pre>HMAC = Tamper-Proof Package Seal</pre><p>Both are valuable.</p><p>Most real-world implementations use both.</p><h3>OAuth vs HMAC</h3><p>This comparison causes confusion more than any other.</p><p>The reality is: <strong>OAuth and HMAC are not competitors.</strong></p><p>They serve different purposes.</p><h3>OAuth</h3><p>Focuses on:</p><pre>Authorization</pre><p>Questions answered:</p><pre>What can this application do?<br>Who granted permission?</pre><h3>HMAC</h3><p>Focuses on:</p><pre>Authentication and Integrity</pre><p>Questions answered:</p><pre>Who sent this message?<br>Was it modified?</pre><h3>When OAuth Wins</h3><p>Choose OAuth when:</p><blockquote>Users are involved</blockquote><blockquote>Consent is required</blockquote><blockquote>Permissions need to be delegated</blockquote><blockquote>Access must be revocable</blockquote><p>Examples:</p><ul><li>Google APIs</li><li>Microsoft Graph</li><li>GitHub Apps</li><li>Open Banking platforms</li></ul><h3>When HMAC Wins</h3><p>Choose HMAC when:</p><blockquote>System-to-system communication</blockquote><blockquote>Payment gateways</blockquote><blockquote>Banking integrations</blockquote><blockquote>Webhooks</blockquote><blockquote>High-volume API traffic</blockquote><blockquote>No user login involved</blockquote><p>Examples:</p><ul><li>Merchant → Payment Processor</li><li>Payment Processor → Webhook Consumer</li><li>Internal Microservices</li><li>Digital Wallet Integrations</li></ul><h3>What About Mutual TLS (mTLS)?</h3><p>Another common option.</p><p>Instead of shared secrets, systems exchange certificates.</p><p>Client:</p><pre>I am Client A</pre><p>Server:</p><pre>Prove it with your certificate</pre><p>Client:</p><pre>Here&#39;s my certificate</pre><p>Server validates it and accepts the connection.</p><h3>Pros</h3><ul><li>Very strong identity verification</li><li>Difficult to impersonate</li></ul><h3>Cons</h3><ul><li>Certificate management overhead</li><li>Renewals and rotations</li><li>Operational complexity</li></ul><p>Because of this, many payment providers combine:</p><pre>mTLS + HMAC</pre><p>for extra security.</p><h3>A Simple Mental Model</h3><p>If a human user is involved:</p><p>👉 Think OAuth.</p><p>If two backend systems are talking directly:</p><p>👉 Think HMAC.</p><p>If identity assurance must be extremely strong:</p><p>👉 Think mTLS.</p><p>If you’re building a quick internal service:</p><p>👉 API Keys may be enough.</p><h3>Final Thoughts</h3><p>There is no single “best” authentication mechanism.</p><p>The right choice depends on the problem you’re solving.</p><p>A good architecture often combines multiple layers:</p><pre>HTTPS<br>   +<br>OAuth<br>   +<br>HMAC<br>   +<br>mTLS</pre><p>Every layer addresses a different risk.</p><p>The most important takeaway is this:</p><blockquote><em>OAuth proves permissions. HMAC proves message integrity. HTTPS protects transport. mTLS proves client identity.</em></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b332627d3da6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Hashing Explained: How Data Becomes a Digital Fingerprint]]></title>
            <link>https://medium.com/@shashirajraja/hashing-explained-how-data-becomes-a-digital-fingerprint-41bac196a94c?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/41bac196a94c</guid>
            <category><![CDATA[hashing]]></category>
            <category><![CDATA[data-security]]></category>
            <category><![CDATA[crypto]]></category>
            <category><![CDATA[hash-function]]></category>
            <category><![CDATA[sha-256]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 06:32:04 GMT</pubDate>
            <atom:updated>2026-07-17T06:32:04.118Z</atom:updated>
            <content:encoded><![CDATA[<h3>Hashing Demystified: How Hash Functions Secure Data</h3><h3>What is Hashing?</h3><ul><li><strong>Definition:</strong> A mathematical function that converts input data into a fixed‑size string of characters.</li><li><strong>Key property:</strong> Even a tiny change in input produces a completely different hash.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*nhw1WqBoow2TMHz0.png" /><figcaption>Truning Data Into a Unique Fingerprint Using Hash Function</figcaption></figure><ul><li>Example:</li></ul><blockquote>Input: hello → Hash: 5d41402abc4b2a76b9719d911017c592</blockquote><blockquote>Input: Hello → Hash: 8b1a9953c4611296a827abf8c47804d7</blockquote><h3>Why Do We Need Hashing?</h3><ul><li><strong>Data Integrity:</strong> Ensures files aren’t tampered with during transfer.</li><li><strong>Password Security:</strong> Websites store hashes, not actual passwords.</li><li><strong>Digital Signatures:</strong> Used in verifying authenticity.</li><li><strong>Blockchain:</strong> Every block is linked by hashes, making tampering nearly impossible.</li></ul><h3>Common Hash Functions</h3><ul><li><strong>MD5:</strong> Fast but outdated (not secure).</li><li><strong>SHA‑1:</strong> Better but still vulnerable.</li><li><strong>SHA‑256:</strong> Widely used today (secure and reliable).</li><li><strong>Others:</strong> SHA‑3, BLAKE2, etc</li></ul><h3>Properties of a Good Hash Function</h3><ul><li><strong>Deterministic:</strong> Same input → same output.</li><li><strong>Irreversible:</strong> You can’t get the original input back from the hash.</li><li><strong>Collision Resistant:</strong> Hard to find two different inputs with the same hash.</li><li><strong>Avalanche Effect:</strong> Small input change → huge hash change.</li></ul><h3>Core security properties</h3><ul><li><strong>Deterministic</strong>: same input → same hash.</li><li><strong>Preimage resistance</strong>: infeasible to recover input from hash.</li><li><strong>Collision resistance</strong>: infeasible to find two inputs with same hash.</li><li><strong>Avalanche effect</strong>: small input change flips many output bits. These properties determine whether a hash is suitable for security uses.</li></ul><h3>Hands‑On Examples</h3><h3>C++ Example (SHA‑256 using OpenSSL)</h3><pre>#include &lt;iostream&gt;<br>#include &lt;openssl/sha.h&gt;<br>#include &lt;iomanip&gt;<br>#include &lt;sstream&gt;<br><br>std::string sha256(const std::string&amp; str) {<br>    unsigned char hash[SHA256_DIGEST_LENGTH];<br>    SHA256((unsigned char*)str.c_str(), str.size(), hash);<br>    std::stringstream ss;<br>    for(int i = 0; i &lt; SHA256_DIGEST_LENGTH; i++)<br>        ss &lt;&lt; std::hex &lt;&lt; std::setw(2) &lt;&lt; std::setfill(&#39;0&#39;) &lt;&lt; (int)hash[i];<br>    return ss.str();<br>}<br><br>int main() {<br>    std::string input = &quot;hello&quot;;<br>    std::cout &lt;&lt; &quot;SHA-256: &quot; &lt;&lt; sha256(input) &lt;&lt; std::endl;<br>    return 0;<br>}</pre><h3>Java Example (SHA‑256)</h3><pre>import java.security.MessageDigest;<br><br>public class HashExample {<br>    public static void main(String[] args) throws Exception {<br>        String input = &quot;hello&quot;;<br>        MessageDigest digest = MessageDigest.getInstance(&quot;SHA-256&quot;);<br>        byte[] hash = digest.digest(input.getBytes(&quot;UTF-8&quot;));<br><br>        StringBuilder hexString = new StringBuilder();<br>        for (byte b : hash) {<br>            String hex = Integer.toHexString(0xff &amp; b);<br>            if(hex.length() == 1) hexString.append(&#39;0&#39;);<br>            hexString.append(hex);<br>        }<br>        System.out.println(&quot;SHA-256: &quot; + hexString.toString());<br>    }<br>}</pre><h3>Node Example (SHA-256 Hash )</h3><pre>// sha256-node.js<br>const crypto = require(&#39;crypto&#39;);<br><br>function sha256(input) {<br>  return crypto.createHash(&#39;sha256&#39;)<br>               .update(input, &#39;utf8&#39;)<br>               .digest(&#39;hex&#39;);<br>}<br><br>// Example usage<br>const text = &#39;hello&#39;;<br>console.log(&#39;Input:&#39;, text);<br>console.log(&#39;SHA-256:&#39;, sha256(text));</pre><h3>Drawbacks and practical risks</h3><ul><li><strong>Broken algorithms</strong>: MD5 and SHA‑1 have practical collision attacks and are unsafe for security uses.</li><li><strong>Speed vs security tradeoff</strong>: very fast hashes (MD5) are easier to brute‑force for passwords; slow, memory‑hard functions are better for passwords.</li><li><strong>No secrecy</strong>: hashes are one‑way; they don’t encrypt data.</li><li><strong>Need for salts and stretching</strong>: password hashing requires unique salts and key stretching (e.g., Argon2) to resist GPU/rainbow attacks.</li></ul><h3>Algorithm comparison</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ASgko4LnV0dsl4QyQIuAdw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sXWdfeShym7VuJa6v3CkEA.png" /></figure><h3>Practical recommendations</h3><ul><li><strong>Do not use MD5 or SHA‑1</strong> for security.</li><li><strong>Use SHA‑256 or SHA‑3</strong> for general integrity and cryptographic needs.</li><li><strong>For passwords use Argon2</strong> (memory‑hard) with unique salts and appropriate parameters.</li><li><strong>Combine hashing with other controls</strong> (TLS, HMAC, rate limits) for real‑world security.</li></ul><h3>Real‑World Applications</h3><ul><li>Password storage in databases.</li><li>File verification (e.g., when downloading software).</li><li>Blockchain and cryptocurrency.</li><li>Digital certificates and signatures.</li></ul><h3>Conclusion</h3><ul><li>Summarize: Hashing is about <strong>trust and security</strong>.</li><li>Encourage students to experiment with hashing functions in code.</li><li>Suggest: Try hashing your own name and see how unique the fingerprint looks.</li></ul><p>Note: Hashing is not encryption. Encryption can be reversed with a key, but hashing is one‑way. That’s why it’s perfect for passwords and integrity checks.</p><p>hashing is powerful but subtle — choose algorithms and parameters that match the threat model, and always salt and stretch passwords.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41bac196a94c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Checksum Made Simple: The Luhn Algorithm Explained]]></title>
            <link>https://medium.com/@shashirajraja/checksum-made-simple-the-luhn-algorithm-explained-8b04352f150b?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/8b04352f150b</guid>
            <category><![CDATA[checksums]]></category>
            <category><![CDATA[credit-card-processing]]></category>
            <category><![CDATA[luhn-algorithm]]></category>
            <category><![CDATA[payments]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Fri, 17 Jul 2026 05:37:04 GMT</pubDate>
            <atom:updated>2026-07-17T05:37:04.127Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Checksum Calculation: The Luhn Algorithm Explained</h3><h3>What is a Checksum?</h3><p>A <strong>checksum</strong> is a small piece of data used to verify the integrity of a larger set of data. Think of it as a digital “spell-check” for numbers or files. When data is transmitted or stored, errors can creep in. A checksum helps detect those errors quickly.</p><ul><li>In simple terms: it’s like adding up digits in a clever way to see if the result matches what’s expected.</li><li>If the checksum doesn’t match, we know something went wrong.</li></ul><h3>Why Do We Need It?</h3><p>Errors happen — whether due to:</p><ul><li>Mistyped digits (like entering a wrong credit card number),</li><li>Transmission glitches,</li><li>Or accidental corruption in storage.</li></ul><p>Checksums are a <strong>first line of defense</strong>. They don’t guarantee perfection, but they catch common mistakes before they cause bigger problems.</p><h3>Where Is It Used?</h3><p>Checksums are everywhere:</p><ul><li><strong>Credit card numbers</strong></li><li><strong>Bank account numbers (IBAN)</strong></li><li><strong>Government IDs</strong></li><li><strong>Data packets in networking</strong></li><li><strong>File downloads (to check integrity)</strong></li></ul><p>One of the most famous checksum methods is the <strong>Luhn Algorithm</strong>, used in almost every credit card number worldwide.</p><h3>The Luhn Algorithm (a.k.a. Mod 10 Check)</h3><p>The <strong>Luhn check</strong> is a simple yet powerful checksum formula designed by IBM scientist Hans Peter Luhn in 1954. It’s specifically built to detect common errors like:</p><ul><li>Single-digit mistakes</li><li>Transposition of adjacent digits.</li></ul><figure><img alt="Infographic illustrating the Luhn Algorithm checksum process for verifying credit card numbers. It shows a sample card number “4539 1488 0343 6467” with rows for position, card digit, after doubling, and final digit used. Arrows highlight which digits are doubled and how two-digit results are reduced. The bottom displays the final sum “80” and the check “80 % 10 = 0 → Valid Number!” with glowing green text and a digital blue background." src="https://cdn-images-1.medium.com/max/576/0*hw-QlVqVmgmwB-AI" /></figure><h3>Step-by-Step Example</h3><p>Let’s check if 4539 1488 0343 6467 is a valid card number.</p><ol><li><strong>Start from the rightmost digit</strong> (the check digit). → 7 is the check digit.</li><li><strong>Double every second digit moving left.</strong></li></ol><blockquote>Digits: 6, 6,4, 0, 8, 1,3, 4→ doubled: 12, 12,8, 0, 16, 2, 6, 8.</blockquote><p><strong>3. If doubling gives a two-digit number, add the digits.</strong></p><blockquote>12 → 1+2 = 3</blockquote><blockquote>16 → 1+6 = 7</blockquote><blockquote>So the transformed sequence becomes: 3, 3,8, 0, 7, 2, 6,8.</blockquote><pre>| Position (from left)  | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |<br>|-----------------------|---|---|---|---|---|---|---|---|---|----|----|----|----|----|----|----|<br>| Card Digit            | 4 | 5 | 3 | 9 | 1 | 4 | 8 | 8 | 0 | 3  | 4  | 3  | 6  | 4  | 6  | 7  |<br>| Double? (Yes/No)      | Y | N | Y | N | Y | N | Y | N | Y | N  | Y  | N  | Y  | N  | Y  | N  |<br>| After Doubling        | 8 | – | 6 | – | 2 | – | 16| – | 0 | –  | 8  | –  | 12 | –  | 12 | –  |<br>| Final Digit Used      | 8 | 5 | 6 | 9 | 2 | 4 | 7 | 8 | 0 | 3  | 8  | 3  | 3  | 4  | 3  | 7  |</pre><p>The above table showcase the calculation for luhn check</p><p><strong>4. Add all digits together (including untouched ones).</strong></p><blockquote>Sum = 8+5+6+9+2+4+7+8+0+3+8+3+3+4+3+7=80</blockquote><p><strong>5. Check divisibility by 10.</strong></p><blockquote>Since 80 % 10 == 0, the number passes the Luhn check.</blockquote><p>✅ This means the card number is <em>structurally valid</em> (though not necessarily active).</p><h3>Why Is Luhn So Popular?</h3><ul><li><strong>Efficiency:</strong> Quick to compute, even by hand.</li><li><strong>Error detection:</strong> Catches most common mistakes.</li><li><strong>Universality:</strong> Adopted across industries (finance, telecom, government).</li><li><strong>Simplicity:</strong> No complex math — just doubling, adding, and checking divisibility.</li></ul><h3>Key Takeaways</h3><ul><li>A <strong>checksum</strong> is a way to verify data integrity.</li><li>The <strong>Luhn Algorithm</strong> is a checksum method used in credit cards and IDs.</li><li>It helps detect typing errors and ensures numbers are valid before processing.</li><li>While it doesn’t guarantee authenticity (a fake card can still pass), it prevents accidental mistakes from clogging systems.</li></ul><h3>C++ Implementation of Luhn Algorithm</h3><pre>#include &lt;iostream&gt;<br>#include &lt;string&gt;<br>using namespace std;<br><br>bool luhnCheck(const string&amp; cardNumber) {<br>    int sum = 0;<br>    bool alternate = false;<br><br>    // Traverse digits from right to left<br>    for (int i = cardNumber.length() - 1; i &gt;= 0; i--) {<br>        int digit = cardNumber[i] - &#39;0&#39;;<br><br>        if (alternate) {<br>            digit *= 2;<br>            if (digit &gt; 9) digit -= 9;<br>        }<br>        sum += digit;<br>        alternate = !alternate;<br>    }<br>    return (sum % 10 == 0);<br>}<br><br>int main() {<br>    string cardNumber;<br>    cout &lt;&lt; &quot;Enter card number: &quot;;<br>    cin &gt;&gt; cardNumber;<br><br>    if (luhnCheck(cardNumber))<br>        cout &lt;&lt; &quot;Valid card number!&quot; &lt;&lt; endl;<br>    else<br>        cout &lt;&lt; &quot;Invalid card number!&quot; &lt;&lt; endl;<br><br>    return 0;<br>}</pre><h3>Java Implementation of Luhn Algorithm</h3><pre>import java.util.Scanner;<br><br>public class LuhnCheck {<br>    public static boolean luhnCheck(String cardNumber) {<br>        int sum = 0;<br>        boolean alternate = false;<br><br>        // Traverse digits from right to left<br>        for (int i = cardNumber.length() - 1; i &gt;= 0; i--) {<br>            int digit = Character.getNumericValue(cardNumber.charAt(i));<br><br>            if (alternate) {<br>                digit *= 2;<br>                if (digit &gt; 9) digit -= 9;<br>            }<br>            sum += digit;<br>            alternate = !alternate;<br>        }<br>        return (sum % 10 == 0);<br>    }<br><br>    public static void main(String[] args) {<br>        Scanner sc = new Scanner(System.in);<br>        System.out.print(&quot;Enter card number: &quot;);<br>        String cardNumber = sc.nextLine();<br><br>        if (luhnCheck(cardNumber))<br>            System.out.println(&quot;Valid card number!&quot;);<br>        else<br>            System.out.println(&quot;Invalid card number!&quot;);<br>    }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8b04352f150b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OpenAPI: The Backbone of Modern API Design]]></title>
            <link>https://medium.com/@shashirajraja/openapi-the-backbone-of-modern-api-design-a9942eb5a8b3?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9942eb5a8b3</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[rest-api]]></category>
            <category><![CDATA[open-api]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Thu, 31 Jul 2025 14:29:57 GMT</pubDate>
            <atom:updated>2025-07-31T14:29:57.366Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s API-first world, OpenAPI has emerged as a cornerstone for designing, documenting, and consuming RESTful APIs. Whether you&#39;re building microservices, integrating third-party services, or enabling developer ecosystems, OpenAPI can streamline your workflow and enhance collaboration across teams.</p><h3>🔍 What is OpenAPI?</h3><p>OpenAPI Specification (OAS) is a standard, language-agnostic format for describing REST APIs. Originally known as Swagger, it allows developers to define endpoints, request/response schemas, authentication methods, and more — all in a human- and machine-readable format (usually YAML or JSON).</p><h3>🛠️ Why Use OpenAPI?</h3><p>Here are some compelling reasons:</p><ul><li>Clear API Contracts: Define your API structure before writing a single line of code.</li><li>Auto-Generated Docs: Tools like Swagger UI or Redoc generate interactive documentation.</li><li>Code Generation: Generate client SDKs or server stubs in multiple languages.</li><li>Validation &amp; Testing: Validate requests/responses against the spec for consistency.</li><li>Mock Servers: Simulate endpoints for frontend/backend parallel development.</li></ul><h3>🧪 A Simple Example</h3><p>Here’s a minimal OpenAPI 3.0 YAML snippet:</p><pre>openapi: 3.0.0<br>info:<br>  title: Product API<br>  version: 1.0.0<br>paths:<br>  /products:<br>    get:<br>      summary: Get all products<br>      responses:<br>        &#39;200&#39;:<br>          description: A list of products</pre><p>This defines a simple GET /products endpoint that returns a list of products.</p><h3>🔧 Tooling Ecosystem</h3><ul><li>Swagger Editor: Write and preview OpenAPI specs in-browser.</li><li>Swagger Codegen / OpenAPI Generator: Generate code from specs.</li><li>Postman: Import OpenAPI specs to create collections and tests.</li><li>Stoplight / Insomnia: Design-first API platforms with OpenAPI support.</li></ul><h3>🚀 Real-World Use Cases</h3><ul><li>E-commerce: Define APIs for product catalogs, carts, and orders.</li><li>Banking/Fintech: Standardize APIs for secure transactions and compliance.</li><li>SaaS Platforms: Enable third-party developers with well-documented APIs.</li></ul><h3>🧭 Best Practices</h3><ul><li>Use components to avoid repetition.</li><li>Keep specs versioned and in source control.</li><li>Validate specs using CI/CD pipelines.</li><li>Document error responses and edge cases.</li></ul><h3>✨ Final Thoughts</h3><p>OpenAPI isn’t just a documentation tool — it’s a contract, a blueprint, and a bridge between teams. Embracing it can lead to faster development, fewer bugs, and better developer experiences.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9942eb5a8b3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Lambda vs Azure Functions: A Comprehensive Comparison]]></title>
            <link>https://medium.com/@shashirajraja/aws-lambda-vs-azure-functions-a-comprehensive-comparison-bae429004a12?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/bae429004a12</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[azure-functions]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Wed, 30 Apr 2025 03:57:01 GMT</pubDate>
            <atom:updated>2025-04-30T03:57:01.019Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Serverless computing has revolutionized the way developers build and deploy applications. AWS Lambda and Azure Functions are two of the most popular serverless platforms, offering Function as a Service (FaaS) capabilities. This blog will delve into the key differences, features, and use cases of AWS Lambda and Azure Functions to help you choose the right platform for your needs.</p><h3>Overview</h3><p>AWS Lambda was introduced by Amazon Web Services in 2014, pioneering the serverless computing model. It allows developers to run code without provisioning or managing servers, charging only for the compute time consumed.</p><p>Azure Functions, launched by Microsoft Azure in 2016, provides similar serverless capabilities, enabling developers to execute code in response to events without worrying about infrastructure.</p><h3>Key Differences</h3><h4>1. Hosting Plans</h4><ul><li>AWS Lambda: Offers a single hosting plan where functions run on Amazon Linux. The cost is based on the number of requests and the duration of execution.</li><li>Azure Functions: Provides multiple hosting options:</li><li>Consumption Plan: Pay-per-use model with automatic scaling.</li><li>Premium Plan: Reserved capacity with advanced networking options.</li><li>App Service Plan: Fixed-cost model with limited auto-scaling.</li><li>Docker Containers: Functions can run in containers on self-managed infrastructure.</li><li>Kubernetes-based Event-Driven Architecture (KEDA): Functions can run on Kubernetes clusters.</li></ul><h4>2. Programming Languages</h4><ul><li>AWS Lambda: Supports Node.js, Python, Java, Go, Ruby, .NET Core, and custom runtimes.</li><li>Azure Functions: Supports C#, JavaScript, F#, Java, Python, PowerShell, TypeScript, and custom runtimes.</li></ul><h4>3. Triggers and Bindings</h4><ul><li>AWS Lambda: Functions can be triggered by various AWS services such as S3, DynamoDB, Kinesis, SNS, and API Gateway.</li><li>Azure Functions: Supports a wide range of triggers including HTTP requests, timers, Azure Blob Storage, Azure Queue Storage, Azure Event Hubs, and more. Bindings simplify the integration with other Azure services.</li></ul><h4>4. Extensibility</h4><ul><li>AWS Lambda: Extensible through AWS Step Functions for orchestration and AWS SAM (Serverless Application Model) for deployment.</li><li>Azure Functions: Extensible through Azure Logic Apps for orchestration and Azure Resource Manager templates for deployment.</li></ul><h4>5. Concurrency and Scaling</h4><ul><li>AWS Lambda: Automatically scales based on the number of incoming requests. Concurrency limits can be configured.</li><li>Azure Functions: Automatically scales based on demand. The Premium Plan offers more control over scaling and concurrency.</li></ul><h4>6. Cost</h4><ul><li>AWS Lambda: Charges based on the number of requests and the duration of execution. The free tier includes 1 million requests and 400,000 GB-seconds of compute time per month.</li><li>Azure Functions: The Consumption Plan charges based on the number of executions and execution time. The Premium Plan and App Service Plan have fixed costs.</li></ul><h3>Use Cases</h3><h4>AWS Lambda</h4><ul><li>Data Processing: Real-time data processing from sources like Kinesis and DynamoDB.</li><li>Web Applications: Backend logic for web applications using API Gateway.</li><li>Automation: Automated tasks triggered by events in AWS services.</li></ul><h4>Azure Functions</h4><ul><li>IoT: Processing data from IoT devices using Event Hubs.</li><li>Integration: Integrating various Azure services using triggers and bindings.</li><li>Webhooks: Handling HTTP requests for webhooks and APIs.</li></ul><h3>Conclusion</h3><p>Both AWS Lambda and Azure Functions offer robust serverless computing capabilities, but they cater to different needs and preferences. AWS Lambda is ideal for those heavily invested in the AWS ecosystem, while Azure Functions provides flexibility with multiple hosting options and seamless integration with Azure services.</p><p>Choosing between AWS Lambda and Azure Functions depends on your specific requirements, existing infrastructure, and preferred programming languages. By understanding the key differences and use cases, you can make an informed decision to leverage the power of serverless computing.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bae429004a12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enabling API Gateway CloudWatch Logs for AWS Applications]]></title>
            <link>https://medium.com/@shashirajraja/enabling-api-gateway-cloudwatch-logs-for-aws-applications-734fc42a1c45?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/734fc42a1c45</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[logs]]></category>
            <category><![CDATA[cloudwatch]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[api-gateway]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Wed, 30 Apr 2025 03:51:03 GMT</pubDate>
            <atom:updated>2025-04-30T03:51:03.540Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>Amazon API Gateway is a powerful service that allows developers to create, publish, maintain, monitor, and secure APIs at any scale. One of the essential features for monitoring and troubleshooting your APIs is enabling CloudWatch logs. CloudWatch logs provide valuable insights into API requests, responses, and errors, helping you maintain the health and performance of your applications.</p><h3>Why Enable CloudWatch Logs?</h3><p>Enabling CloudWatch logs for API Gateway offers several benefits:</p><ul><li>Debugging: Helps identify and troubleshoot issues with API requests and responses.</li><li>Monitoring: Provides visibility into API usage and performance.</li><li>Security: Logs can help detect unauthorized access and other security issues.</li><li>Compliance: Assists in meeting regulatory requirements by providing detailed logs of API activity.</li></ul><h3>Types of Logs</h3><p>API Gateway supports two types of logging:</p><ol><li>Execution Logging: Logs detailed information about API requests and responses, including errors and execution traces.</li><li>Access Logging: Logs information about who accessed your API and how they accessed it.</li></ol><h3>Steps to Enable CloudWatch Logs</h3><h4>Step 1: Create an IAM Role</h4><p>To enable CloudWatch logs, you need to create an IAM role that grants API Gateway permission to write logs to CloudWatch.</p><ol><li>Open the AWS Identity and Access Management (IAM) console.</li><li>In the navigation pane, choose Roles.</li><li>Choose Create role.</li><li>Select AWS Service as the trusted entity and choose API Gateway.</li><li>Attach the AmazonAPIGatewayPushToCloudWatchLogs managed policy.</li><li>Name the role and create it.</li></ol><h4>Step 2: Configure API Gateway to Use the IAM Role</h4><ol><li>Open the API Gateway console.</li><li>Select your API.</li><li>In the navigation pane, choose Settings.</li><li>Enter the IAM role’s ARN in the CloudWatch log role ARN field.</li><li>Save the settings.</li></ol><h4>Step 3: Enable Logging for Your API Stage</h4><ol><li>In the API Gateway console, select your API.</li><li>In the navigation pane, choose Stages.</li><li>Select the stage you want to enable logging for.</li><li>Under Logs/Tracing, choose Edit.</li><li>Enable CloudWatch Logs and select the desired logging level (e.g., ERROR, INFO).</li><li>Save the changes.</li></ol><h3>Customizing Log Formats</h3><p>You can customize the log format for access logging using $context variables. Some useful variables include:</p><ul><li>$context.requestId: The unique request ID.</li><li>$context.extendedRequestId: The extended request ID.</li><li>$context.identity.sourceIp: The source IP address of the request.</li></ul><p>Example log format:</p><pre>{<br>  &quot;requestId&quot;: &quot;$context.requestId&quot;,<br>  &quot;extendedRequestId&quot;: &quot;$context.extendedRequestId&quot;,<br>  &quot;sourceIp&quot;: &quot;$context.identity.sourceIp&quot;,<br>  &quot;userAgent&quot;: &quot;$context.identity.userAgent&quot;,<br>  &quot;requestTime&quot;: &quot;$context.requestTime&quot;<br>}</pre><h3>Best Practices</h3><ul><li>Log Levels: Use appropriate log levels (ERROR, INFO) to avoid logging sensitive data.</li><li>Data Tracing: Avoid enabling data tracing for production APIs to prevent logging sensitive information.</li><li>Monitoring: Regularly review logs to monitor API performance and security.</li></ul><h3>Conclusion</h3><p>Enabling CloudWatch logs for API Gateway is a crucial step in maintaining and troubleshooting your AWS applications. By following the steps outlined above, you can gain valuable insights into your API’s performance and security, ensuring a robust and reliable application.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=734fc42a1c45" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastercard Payment Gateway Services (MPGS)]]></title>
            <link>https://medium.com/@shashirajraja/mastercard-payment-gateway-services-mpgs-cbf585e040a1?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbf585e040a1</guid>
            <category><![CDATA[payments]]></category>
            <category><![CDATA[gmp]]></category>
            <category><![CDATA[payment-processing]]></category>
            <category><![CDATA[payment-gateway]]></category>
            <category><![CDATA[card-payment]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Thu, 06 Mar 2025 11:23:11 GMT</pubDate>
            <atom:updated>2025-03-06T11:23:11.027Z</atom:updated>
            <content:encoded><![CDATA[<p>Mastercard Payment Gateway Services (MPGS) is a robust platform designed to facilitate secure and efficient payment processing for businesses worldwide.</p><blockquote><strong>Introduction to Mastercard Payment Gateway</strong><br>Mastercard Payment Gateway Services (MPGS) is a globally recognized payment platform that empowers businesses to handle transactions efficiently and securely. Designed to cater to a wide variety of industries, MPGS supports merchants in accepting payments across multiple channels, including e-commerce, mobile apps, and in-store payments.</blockquote><p><strong>Key highlights</strong></p><ul><li><strong><em>Global Reach:</em></strong> MPGS is accessible in multiple countries and currencies, ensuring businesses can cater to international customer</li><li><strong>Comprehensive Solutions</strong>: It offers a one-stop platform to manage payments, refunds, and chargebacks seamlessly.</li><li><strong>Developer-Friendly Tools:</strong> APIs, SDKs, and other integration options simplify adoption.</li></ul><p><strong>How MPGS Works : </strong><br>The payment processing workflow involves the following key steps:</p><ul><li>Customer Interaction:<br>The customer initiates a transaction by providing payment details (e.g., card number, expiration date, etc.).</li><li>Data Transmission:<br>Payment details are sent securely to MPGS, leveraging advanced encryption protocols.</li><li>Authentication:<br>Additional verification like 3D Secure (e.g., EMV 3DS) may be triggered for customer authentication.</li><li>Authorization:<br>MPGS forwards transaction details to the card-issuing bank for approval.</li><li>Confirmation:<br>The transaction is either approved or declined. The results are communicated back to the merchant and the customer in real-time.</li></ul><p>Integration options:</p><ul><li>APIs: Developers can use RESTful APIs to customize payment solutions according to business needs.</li><li>Hosted Checkout: A pre-designed, secure payment page for quick implementation.</li><li>Mobile SDKs: For seamless integration into iOS and Android apps.</li></ul><p><strong>Security Features</strong><br>MPGS prioritizes security to protect sensitive customer data and prevent fraudulent activities:</p><ul><li>Tokenization: Sensitive card details are replaced with unique tokens, ensuring data is secure during transactions.</li><li>PCI DSS Compliance: MPGS adheres to the Payment Card Industry Data Security Standard, a stringent set of requirements to secure cardholder data.</li><li>Fraud Management Tools:</li><li>Risk Monitoring: Real-time tools analyze transaction patterns for potential fraud.</li><li>Customizable Rules Engine: Merchants can set rules to filter suspicious transactions.</li></ul><p><strong>Benefits for Businesses</strong><br>Businesses adopting MPGS benefit in the following ways:</p><ul><li>Unified Platform: A centralized dashboard for managing payment-related operations.</li><li>Multi-Channel Support: Accept payments from various platforms, such as websites, apps, and even social media.</li><li>Scalability: As businesses grow, MPGS can handle increasing transaction volumes without performance degradation.</li><li>Currency Conversion: Supports dynamic currency conversion to enhance convenience for global customers.</li></ul><p><strong><em>Use Cases</em></strong></p><p>MPGS finds applications across various industries:</p><ul><li>E-commerce: Enhances the checkout experience with one-click payments and subscription billing.</li><li>Hospitality: Integrates with booking platforms for seamless payments.</li><li>Retail: Supports in-store card-present transactions alongside online purchases.</li><li>Non-Profits: Enables recurring donations via secure payment links.</li></ul><p>Example:<br>A global retail chain with both online and offline stores could use MPGS to unify its payment infrastructure. The platform’s comprehensive reporting tools allow the retailer to monitor performance across regions.</p><p><strong>Future of Payment Gateways</strong></p><p>The payments landscape is evolving rapidly, and MPGS is keeping pace with innovations:</p><ul><li>EMV 3DS: Enhanced customer authentication for secure online shopping.</li><li>Subscription Payments: Enabling businesses to offer subscription models with automated billing.</li><li>AI-Driven Fraud Detection: Leveraging artificial intelligence to identify and block fraud in real-time.</li><li>Voice Commerce: Supporting voice-activated payments for smart devices.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbf585e040a1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Best Practices for Implementing Spring Security: A Comprehensive Guide]]></title>
            <link>https://medium.com/@shashirajraja/best-practices-for-implementing-spring-security-a-comprehensive-guide-d5d8f4891146?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5d8f4891146</guid>
            <category><![CDATA[jwt]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[spring-security]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[oauth]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Mon, 23 Sep 2024 02:36:49 GMT</pubDate>
            <atom:updated>2024-09-23T02:36:49.727Z</atom:updated>
            <content:encoded><![CDATA[<p>Spring Security is a powerful framework that helps secure Java applications, offering capabilities such as authentication, authorization, and other security-related features. However, as with any security tool, its effectiveness depends on how well it is implemented. In this guide, we&#39;ll explore some of the best practices for implementing <strong>Spring Security</strong> to make your applications more robust and secure.</p><h3>1. Use the Latest Version of Spring Security</h3><p>Security vulnerabilities and bugs are continuously discovered and fixed in software libraries. Always use the latest stable version of <strong>Spring Security</strong> to ensure you have access to the latest security patches, features, and improvements. Regularly checking for updates and upgrading your dependencies can protect your application from known vulnerabilities.</p><h4>Why It Matters:</h4><ul><li>Older versions may have unpatched security flaws.</li><li>Newer versions often include performance improvements and more secure defaults.</li></ul><h4>2. Secure by Default with @EnableGlobalMethodSecurity</h4><p>Method-level security in Spring can be enforced by using annotations such as @PreAuthorize, @PostAuthorize, @Secured, and @RolesAllowed. To enable this, you should annotate your configuration class with @EnableGlobalMethodSecurity(prePostEnabled = true).</p><p>Using method-level security annotations ensures that access to sensitive methods is controlled and checked consistently.</p><pre>@Configuration<br>@EnableGlobalMethodSecurity(prePostEnabled = true)<br>public class SecurityConfig extends WebSecurityConfigurerAdapter {<br>    // Your configuration here<br>}</pre><h4>Why It Matters:</h4><ul><li>Ensures fine-grained control over access to specific methods.</li><li>Reduces the risk of unauthorized access to critical operations.</li></ul><h3>3. Use PasswordEncoder to Hash Passwords</h3><p>Passwords should never be stored in plain text. Always use a PasswordEncoder to hash passwords before saving them to a database. Spring Security provides implementations like BCryptPasswordEncoder, which is a secure and widely recommended hashing algorithm.</p><pre>@Bean<br>public PasswordEncoder passwordEncoder() {<br>    return new BCryptPasswordEncoder();<br>}</pre><h4>Why It Matters:</h4><ul><li>Plain text passwords expose users to significant risk if the database is compromised.</li><li>Secure hashing algorithms make it difficult for attackers to reverse-engineer passwords.</li></ul><h3>4. Enable CSRF Protection for Stateless Applications</h3><p>Cross-Site Request Forgery (CSRF) attacks can compromise the integrity of your application, especially in web applications with forms or API endpoints that modify data. Spring Security has CSRF protection enabled by default for web forms, but in stateless REST APIs, you can disable it if using JWT or OAuth for token-based authentication.</p><p>If you are building a traditional web application, keep CSRF protection enabled.</p><pre>@Override<br>protected void configure(HttpSecurity http) throws Exception {<br>    http<br>        .csrf()<br>        .disable();  // Disable CSRF only for stateless REST APIs<br>}</pre><h4>Why It Matters:</h4><ul><li>Protects against unauthorized requests initiated by third parties.</li><li>Helps prevent malicious data modification or unauthorized transactions.</li></ul><h3>5. Use JWT (JSON Web Tokens) for Stateless Authentication</h3><p>For modern REST APIs, it&#39;s common to implement stateless authentication using JSON Web Tokens (JWTs). JWT tokens contain the user&#39;s claims and can be used across distributed services without needing server-side session management. JWT can be integrated with Spring Security to secure endpoints.</p><h4>Key Steps for JWT Integration:</h4><ol><li>Generate a JWT token upon successful login.</li><li>Include the token in the Authorization header of each request.</li><li>Create a custom filter to extract and validate the JWT from incoming requests.</li></ol><pre>@Override<br>protected void configure(HttpSecurity http) throws Exception {<br>    http<br>        .authorizeRequests()<br>        .anyRequest().authenticated()<br>        .and()<br>        .addFilter(new JwtAuthenticationFilter(authenticationManager()));<br>}</pre><h4>Why It Matters:</h4><ul><li>JWT provides scalability by eliminating the need for session management.</li><li>Secure and portable token format.</li></ul><h3>6. Limit Exposure to Public Endpoints</h3><p>By default, all routes should be secured and require authentication. Explicitly define which endpoints are public and accessible without authentication, such as login and registration pages.</p><pre>@Override<br>protected void configure(HttpSecurity http) throws Exception {<br>    http<br>        .authorizeRequests()<br>        .antMatchers(&quot;/login&quot;, &quot;/register&quot;).permitAll()<br>        .anyRequest().authenticated();<br>}</pre><h4>Why It Matters:</h4><ul><li>Minimizes attack surface by securing all endpoints except for the ones that need to be public.</li><li>Prevents unauthorized access to critical endpoints.</li></ul><h3>7. Use Role-Based Access Control (RBAC)</h3><p>For large applications, implementing <strong>Role-Based Access Control (RBAC)</strong> helps simplify permission management. Define roles such as ROLE_USER, ROLE_ADMIN, and use method-level security or configuration-based access rules to restrict access based on roles.</p><pre>@PreAuthorize(&quot;hasRole(&#39;ADMIN&#39;)&quot;)<br>public String adminDashboard() {<br>    return &quot;admin-dashboard&quot;;<br>}</pre><h4>Why It Matters:</h4><ul><li>Simplifies permission management by grouping permissions into roles.</li><li>Makes it easier to scale access control as the application grows.</li></ul><h3>8. Enable HTTPS and Secure Cookies</h3><p>Ensure that all communications between clients and servers are encrypted by enabling <strong>HTTPS</strong>. Additionally, ensure that cookies used for session management or authentication are secure and flagged with HttpOnly and Secure attributes.</p><ul><li><strong>HttpOnly</strong>: Prevents client-side JavaScript from accessing cookies, mitigating XSS attacks.</li><li><strong>Secure</strong>: Ensures cookies are only sent over HTTPS connections.</li></ul><pre>http<br>    .requiresChannel()<br>    .anyRequest()<br>    .requiresSecure();</pre><h4>Why It Matters:</h4><ul><li>Prevents data eavesdropping and man-in-the-middle attacks.</li><li>Ensures secure cookie handling.</li></ul><h3>9. Implement Exception Handling and Custom Error Responses</h3><p>Handling authentication and authorization failures gracefully is crucial. Customize access-denied messages, authentication failure responses, and handle exceptions globally to provide meaningful error messages to the client while not exposing sensitive information.</p><pre>@Override<br>protected void configure(HttpSecurity http) throws Exception {<br>    http<br>        .exceptionHandling()<br>        .accessDeniedHandler(new CustomAccessDeniedHandler())<br>        .authenticationEntryPoint(new CustomAuthenticationEntryPoint());<br>}</pre><h4>Why It Matters:</h4><ul><li>Provides a better user experience by delivering clear error messages.</li><li>Prevents leaking sensitive information in error responses.</li></ul><h3>10. Audit and Monitor Authentication Events</h3><p>Implement logging for authentication and access control events. This provides an audit trail for security incidents and helps in detecting suspicious behavior or access attempts. Spring Security provides hooks to customize authentication success and failure handling, which you can use to log relevant events.</p><pre>@Override<br>protected void configure(HttpSecurity http) throws Exception {<br>    http<br>        .formLogin()<br>        .successHandler(new CustomAuthenticationSuccessHandler())<br>        .failureHandler(new CustomAuthenticationFailureHandler());<br>}</pre><h4>Why It Matters:</h4><ul><li>Helps with compliance and security auditing.</li><li>Detects potential unauthorized access or brute force attacks.</li></ul><h3>11. Implement Rate Limiting and Throttling</h3><p>To protect against brute-force attacks on authentication endpoints (such as login forms), implement rate limiting and request throttling. Spring Security can be integrated with tools like <strong>Bucket4j</strong> or AWS WAF to restrict the number of login attempts from a single IP address or user.</p><pre>// Sample usage of a rate-limiting interceptor<br>@Bean<br>public FilterRegistrationBean rateLimitingFilter() {<br>    FilterRegistrationBean registration = new FilterRegistrationBean();<br>    registration.setFilter(new RateLimitingFilter());<br>    return registration;<br>}</pre><h4>Why It Matters:</h4><ul><li>Reduces the risk of automated attacks, such as brute-force login attempts.</li><li>Protects your application from denial-of-service (DoS) attacks.</li></ul><h3>Conclusion</h3><p>Spring Security is a comprehensive and highly configurable security framework, but implementing it effectively requires attention to best practices. By focusing on secure defaults, protecting sensitive endpoints, managing user roles carefully, and enforcing encryption, you can build robust, scalable, and secure Java applications.</p><p>By adopting these best practices, you not only secure your Spring-based applications but also improve scalability, maintainability, and performance while ensuring a secure and seamless experience for users.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5d8f4891146" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS CloudFormation]]></title>
            <link>https://medium.com/@shashirajraja/aws-cloudformation-dcd42e72bfdd?source=rss-2339b0a1ffc9------2</link>
            <guid isPermaLink="false">https://medium.com/p/dcd42e72bfdd</guid>
            <category><![CDATA[cloudformation]]></category>
            <category><![CDATA[aws-cloud]]></category>
            <category><![CDATA[aws-cloudformation]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[amazon-web-services]]></category>
            <dc:creator><![CDATA[Shashi Raj]]></dc:creator>
            <pubDate>Mon, 23 Sep 2024 02:26:57 GMT</pubDate>
            <atom:updated>2024-09-23T02:26:57.168Z</atom:updated>
            <content:encoded><![CDATA[<p>As organizations embrace cloud computing to modernize their IT infrastructure, managing and provisioning resources in the cloud becomes a critical task. AWS (Amazon Web Services) offers a powerful tool to automate the creation, deployment, and management of infrastructure — <strong>AWS CloudFormation</strong>. In this blog, we’ll explore the workings of AWS CloudFormation, its key features, and why it’s an essential tool for developers and cloud architects.</p><h3>What is AWS CloudFormation?</h3><p>AWS CloudFormation is an Infrastructure as Code (IaC) service that allows users to define and provision AWS resources using JSON or YAML templates. Instead of manually configuring each resource in the AWS Management Console, you can define the infrastructure required for your application in a template file, which CloudFormation uses to provision, manage, and update your resources automatically.</p><p>In simple terms, AWS CloudFormation allows you to treat your infrastructure the same way you treat code: as files that can be versioned, tested, and deployed consistently.</p><h3>Key Concepts in AWS CloudFormation</h3><p>Before we dive into how AWS CloudFormation works, let’s look at some key concepts:</p><ul><li><strong>Stacks</strong>: A stack is the collection of AWS resources that CloudFormation creates and manages based on your template. You can think of a stack as a deployment unit where all related infrastructure components (such as EC2 instances, RDS databases, and security groups) are grouped together.</li><li><strong>Templates</strong>: Templates are the heart of CloudFormation. These are JSON or YAML files that define the resources, configurations, and parameters for your stack. A template is essentially the blueprint that AWS CloudFormation follows to create and configure resources.</li><li><strong>Resources</strong>: Resources are the AWS services and components (such as S3 buckets, Lambda functions, or EC2 instances) defined in the template. CloudFormation supports a wide range of AWS services that can be declared as resources.</li><li><strong>Parameters</strong>: Parameters allow you to pass values into your template at runtime. This makes your templates reusable by enabling customization without hard-coding specific values, such as instance types, environment names, or VPC IDs.</li><li><strong>Outputs</strong>: Outputs are values that CloudFormation returns once the stack is created. You can use outputs to expose information, like IP addresses or resource names, for easy access.</li><li><strong>Change Sets</strong>: A change set shows the differences between your existing stack and proposed updates to the stack. This allows you to preview changes before applying them, reducing the risk of unintended disruptions.</li></ul><h3>How Does AWS CloudFormation Work?</h3><ol><li><strong>Create a Template</strong>: The process begins by writing a CloudFormation template. This template specifies the AWS resources you want to create, including their configurations and dependencies. Templates are written in JSON or YAML, and AWS provides a number of sample templates and tools to help you get started.</li><li><strong>Deploy the Stack</strong>: Once your template is ready, you submit it to AWS CloudFormation. CloudFormation processes the template and starts provisioning the resources you’ve defined. Each stack corresponds to a single deployment of a template.</li><li><strong>Provisioning Resources</strong>: CloudFormation manages the entire lifecycle of the resources in your stack. This includes not only creating resources but also handling updates and deletions. AWS CloudFormation takes care of any dependencies between resources, ensuring that the correct order is followed (e.g., creating an S3 bucket before a Lambda function that needs to access it).</li><li><strong>Monitor the Stack</strong>: As CloudFormation creates resources, it monitors their progress. You can track the status of your stack in the AWS Management Console, where you’ll see messages like “CREATE_IN_PROGRESS” or “CREATE_COMPLETE.” If any errors occur, CloudFormation will attempt to roll back the changes to maintain consistency.</li><li><strong>Manage Updates with Change Sets</strong>: When you want to update your stack (e.g., to add a new resource or modify an existing one), you create a change set. This change set allows you to preview the proposed changes before they’re applied. Once you’re satisfied with the changes, you can execute the change set to update the stack.</li><li><strong>Delete the Stack</strong>: When a stack is no longer needed, CloudFormation can delete it. This will automatically clean up all associated resources, ensuring you don’t leave behind unused infrastructure.</li></ol><h3>Key Features of AWS CloudFormation</h3><ul><li><strong>Infrastructure as Code (IaC)</strong>: AWS CloudFormation allows you to define your entire infrastructure in code. This provides benefits such as version control, reproducibility, and automation.</li><li><strong>Declarative Model</strong>: CloudFormation uses a declarative model, meaning you define the desired state of your infrastructure, and AWS handles the “how” part of making it happen. You don’t need to manually specify the sequence of operations; CloudFormation figures it out based on dependencies.</li><li><strong>Automatic Rollback</strong>: If an error occurs during the creation or update of a stack, CloudFormation automatically rolls back to the last known good state. This ensures that your infrastructure remains consistent and operational even if something goes wrong.</li><li><strong>Cross-Stack References</strong>: CloudFormation supports cross-stack references, which allow you to share resources between stacks. This is useful in large environments where resources need to be reused across different parts of an application.</li><li><strong>Stack Sets</strong>: For enterprises managing multiple AWS accounts or regions, CloudFormation StackSets allow you to deploy and manage stacks across multiple accounts and regions with a single operation. This is especially useful for managing global infrastructures.</li><li><strong>Drift Detection</strong>: CloudFormation drift detection allows you to detect when the actual state of your resources differs from what is defined in your template. This helps in identifying any manual changes that may have been made outside of CloudFormation.</li></ul><h3>Benefits of AWS CloudFormation</h3><ul><li><strong>Simplified Resource Management</strong>: CloudFormation automates the creation, update, and deletion of AWS resources. By automating infrastructure management, you reduce human error and save time.</li><li><strong>Consistency and Repeatability</strong>: Since CloudFormation templates are reusable, you can replicate your infrastructure consistently across different environments, such as development, testing, and production. This reduces the chances of configuration drift between environments.</li><li><strong>Version Control</strong>: CloudFormation templates can be versioned just like application code. This means you can track changes, revert to previous versions, and even use Git or other version control systems to collaborate on infrastructure development.</li><li><strong>Cost Management</strong>: CloudFormation allows you to easily delete entire stacks when no longer needed, helping to prevent resource sprawl and manage cloud costs. Additionally, the ability to preview changes with change sets reduces the risk of unplanned costs.</li><li><strong>Integration with Other AWS Services</strong>: CloudFormation integrates with many AWS services, making it easier to manage resources and automate workflows. For example, you can use AWS CodePipeline to trigger CloudFormation deployments as part of a continuous integration/continuous deployment (CI/CD) pipeline.</li></ul><h3>Best Practices for AWS CloudFormation</h3><ul><li><strong>Modularize Your Templates</strong>: Instead of creating one large template for everything, break your templates into smaller, reusable modules. This makes them easier to manage, update, and debug.</li><li><strong>Use Parameters and Outputs</strong>: Leverage parameters to make your templates more flexible and reusable across environments. Use outputs to expose key values, like resource ARNs or IP addresses, which can be referenced by other stacks.</li><li><strong>Test Changes with Change Sets</strong>: Always use change sets when updating stacks to preview the impact of your changes and avoid unintended disruptions.</li><li><strong>Enable Rollbacks</strong>: By default, CloudFormation rolls back changes when an error occurs. This is a valuable safeguard to ensure your infrastructure remains stable.</li></ul><h3>Conclusion</h3><p>AWS CloudFormation is a powerful tool for automating the provisioning and management of AWS infrastructure. By treating infrastructure as code, CloudFormation enables organizations to scale, maintain, and update their cloud resources consistently and efficiently. With features like change sets, cross-stack references, and drift detection, CloudFormation ensures that your infrastructure remains predictable and secure.</p><p>Whether you’re managing a small application or a complex multi-region architecture, AWS CloudFormation helps you automate, streamline, and optimize your infrastructure management. If you haven’t explored AWS CloudFormation yet, it’s time to dive in and leverage its full potential for your cloud projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dcd42e72bfdd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>