<?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 Sabih Hida Tahir on Medium]]></title>
        <description><![CDATA[Stories by Sabih Hida Tahir on Medium]]></description>
        <link>https://medium.com/@sabihhida88?source=rss-100184599811------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*nun8_fYaYgyQdXgm2zvbSA.jpeg</url>
            <title>Stories by Sabih Hida Tahir on Medium</title>
            <link>https://medium.com/@sabihhida88?source=rss-100184599811------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 23:42:19 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sabihhida88/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[When Backend-Driven UI Becomes a Problem in iOS]]></title>
            <link>https://medium.com/@sabihhida88/when-backend-driven-ui-becomes-a-problem-in-ios-6a1c719817d4?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/6a1c719817d4</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[backend-driven-ui]]></category>
            <category><![CDATA[api-driven-ui]]></category>
            <category><![CDATA[mobile-app-architecture]]></category>
            <category><![CDATA[ios-architecture]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Fri, 18 Sep 2026 12:33:59 GMT</pubDate>
            <atom:updated>2026-09-18T12:40:49.977Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Subtitle:</strong><br>Backend-driven UI can make products faster and more flexible — but pushing too much UI responsibility to the server can create architectural, release, and App Store challenges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kf2x1WBwawANXUsbP9MGWA.png" /></figure><h3>The Backend Can Change the UI. But Should It Control Everything?</h3><p>Imagine this.</p><p>You release an iOS app to the App Store.</p><p>A few days later, the product team says:</p><blockquote><em>“We need to change the home screen.”</em></blockquote><p>Normally, that could mean:</p><pre>Requirement<br>    ↓<br>iOS Development<br>    ↓<br>Testing<br>    ↓<br>App Store Review<br>    ↓<br>Release</pre><p>But with a backend-driven UI system, the flow can become:</p><pre>Backend Configuration<br>        ↓<br>API Response<br>        ↓<br>iOS Renderer<br>        ↓<br>New UI</pre><p>No new binary is required for every content or configuration change.</p><p>That sounds great.</p><p>And sometimes, it is.</p><p>Backend-driven UI can be extremely useful for:</p><ul><li>feature flags</li><li>content ordering</li><li>campaigns</li><li>localization</li><li>experiments</li><li>server-controlled content</li><li>configuration</li><li>seasonal experiences</li></ul><p>But there is an important architectural question:</p><blockquote><strong><em>Where should the boundary between the backend and the iOS application actually be?</em></strong></blockquote><p>Because once the backend starts controlling too much of the interface, flexibility can turn into complexity.</p><h3>What Is Backend-Driven UI?</h3><p>Backend-driven UI, often called <strong>server-driven UI</strong>, means that the server provides information that determines some aspects of the application’s interface.</p><p>A simplified API response might look like:</p><pre>{<br>  &quot;screen&quot;: &quot;home&quot;,<br>  &quot;sections&quot;: [<br>    {<br>      &quot;type&quot;: &quot;banner&quot;,<br>      &quot;title&quot;: &quot;Watch Live&quot;,<br>      &quot;imageURL&quot;: &quot;...&quot;<br>    },<br>    {<br>      &quot;type&quot;: &quot;horizontal_list&quot;,<br>      &quot;title&quot;: &quot;Trending&quot;,<br>      &quot;items&quot;: []<br>    }<br>  ]<br>}</pre><p>The iOS application receives this information and maps it to native components.</p><p>Conceptually:</p><pre>Backend<br>   ↓<br>JSON / Configuration<br>   ↓<br>UI Model<br>   ↓<br>Renderer<br>   ↓<br>UIKit / SwiftUI</pre><p>The application isn’t deciding every piece of content at compile time.</p><p>Instead, the server is providing instructions or configuration that the client understands.</p><h3>Why Teams Like Backend-Driven UI</h3><p>There are some very legitimate reasons to use it.</p><h3>1. Faster Content Changes</h3><p>Marketing teams may want to change:</p><ul><li>banners</li><li>promotional sections</li><li>content ordering</li><li>campaigns</li><li>labels</li><li>without waiting for a new app release.</li></ul><p>For a content-heavy application, this can be extremely valuable.</p><h3>2. Feature Flags</h3><p>Backend configuration can determine whether a feature is enabled:</p><pre>{<br>  &quot;newPlayer&quot;: true<br>}</pre><p>The client can then decide whether to activate an already-implemented feature.</p><p>This is an important distinction:</p><blockquote><strong><em>The backend can decide whether an existing capability is enabled without defining an entirely new capability.</em></strong></blockquote><h3>3. A/B Testing</h3><p>Suppose the product team wants to test two versions of a screen.</p><p>The server can return:</p><pre>Variant A</pre><p>or:</p><pre>Variant B</pre><p>The iOS application can render both using components already supported by the client.</p><h3>4. Regional Experiences</h3><p>A global application may need different content for different markets.</p><p>For example:</p><pre>Pakistan<br>    ↓<br>Sports + Local Content</pre><pre>Bangladesh<br>    ↓<br>Cricket + Local Content</pre><pre>USA<br>    ↓<br>Different Content Mix</pre><p>Backend configuration can make these differences easier to manage.</p><h3>So What’s the Problem?</h3><p>The problem starts when backend-driven UI moves from:</p><blockquote><strong><em>“The backend controls configuration.”</em></strong></blockquote><p>to:</p><blockquote><strong><em>“The backend controls the application’s entire interface.”</em></strong></blockquote><p>These are very different architectural decisions.</p><p>Consider a hypothetical response:</p><pre>{<br>  &quot;component&quot;: &quot;tab_bar&quot;,<br>  &quot;tabs&quot;: [<br>    {<br>      &quot;title&quot;: &quot;Home&quot;,<br>      &quot;icon&quot;: &quot;home&quot;<br>    },<br>    {<br>      &quot;title&quot;: &quot;Sports&quot;,<br>      &quot;icon&quot;: &quot;sports&quot;<br>    },<br>    {<br>      &quot;title&quot;: &quot;Profile&quot;,<br>      &quot;icon&quot;: &quot;profile&quot;<br>    }<br>  ]<br>}</pre><p>At first, this looks flexible.</p><p>But now ask:</p><ul><li>What if the backend sends an unsupported tab?</li><li>What if an icon doesn’t exist in the installed version?</li><li>What if navigation behavior changes?</li><li>What if a new component is introduced?</li><li>What happens when an older app version receives newer configuration?</li><li>What happens when the API is unavailable?</li><li>What happens if the server configuration is incorrect?</li></ul><p>The UI is no longer only an iOS concern.</p><p>It has become a <strong>distributed system problem</strong>.</p><h3>The Version Compatibility Problem</h3><p>This is one of the biggest challenges.</p><p>Imagine version 1 of your app understands:</p><pre>banner<br>carousel<br>grid</pre><p>Later, the backend introduces:</p><pre>interactive_poll</pre><p>But the user hasn’t updated the app.</p><p>What happens?</p><p>The client doesn’t understand the new component.</p><p>You need a compatibility strategy.</p><p>For example:</p><pre>{<br>  &quot;type&quot;: &quot;interactive_poll&quot;,<br>  &quot;minAppVersion&quot;: &quot;20.50&quot;<br>}</pre><p>The server can then avoid sending unsupported components to older clients.</p><p>This is why server-driven UI isn’t simply a UI problem.</p><p>It’s a <strong>versioning problem</strong>.</p><h3>The Client Still Needs to Be Defensive</h3><p>A backend-driven architecture should never assume that the server will always send perfect data.</p><p>For example:</p><pre>switch component.type {<br>case .banner:<br>    renderBanner(component)</pre><pre>case .carousel:<br>    renderCarousel(component)</pre><pre>case .grid:<br>    renderGrid(component)</pre><pre>default:<br>    renderFallback()<br>}</pre><p>Unknown components should not crash the application.</p><p>The client needs graceful degradation.</p><p>A good rule is:</p><blockquote><strong><em>Never let a backend configuration mistake become an application crash.</em></strong></blockquote><h3>The Offline Problem</h3><p>What happens when the user opens the application without a network connection?</p><p>If critical UI depends entirely on the server, the application may not know what to display.</p><p>This is especially problematic for foundational UI such as:</p><ul><li>navigation</li><li>authentication</li><li>settings</li><li>core tabs</li><li>error states</li><li>basic application structure</li></ul><p>A resilient application should have a sensible fallback.</p><p>For example:</p><pre>Server Configuration<br>        ↓<br>    Available?<br>   /          \<br> Yes           No<br> ↓              ↓<br>Render         Native<br>Config         Fallback</pre><p>The backend should enhance the experience — not necessarily become a single point of failure for the entire application.</p><h3>App Store Considerations</h3><p>There is another reason to be careful.</p><p>Apple’s App Store Review Guidelines include rules around applications downloading or executing code and changing functionality after review.</p><p>This doesn’t mean backend-driven UI is automatically prohibited.</p><p>Many applications legitimately use remote configuration and server-provided content.</p><p>The important distinction is between:</p><p><strong>Configuration/content</strong></p><p>and</p><p><strong>introducing functionality that wasn’t part of the reviewed application.</strong></p><p>For example, controlling the order of existing native components is conceptually different from downloading an entirely new executable implementation after review.</p><p>So when designing a backend-driven system, the architecture should respect the platform’s rules rather than treating the backend as a way around the app release process.</p><h3>Backend-Driven UI vs Native UI</h3><p>The choice doesn’t have to be binary.</p><p>You don’t necessarily have to choose:</p><pre>100% Native</pre><p>or:</p><pre>100% Backend Driven</pre><p>A hybrid approach is often more practical.</p><p>For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XgJmMPlnA3IoBR89LFwe0g.png" /></figure><p>The exact boundary depends on the application.</p><p>But the principle is important:</p><blockquote><strong><em>Let the server control what changes frequently. Let the client own what defines application behavior and platform integration.</em></strong></blockquote><h3>A Better Architecture</h3><p>Instead of allowing the backend to directly dictate UIKit or SwiftUI views, introduce an intermediate model.</p><pre>                Backend<br>                   ↓<br>                API JSON<br>                   ↓<br>             Configuration<br>                   ↓<br>             UI Domain Model<br>                   ↓<br>          ┌────────┴────────┐<br>          ↓                 ↓<br>       UIKit             SwiftUI</pre><p>For example:</p><pre>enum HomeComponent {<br>    case banner(BannerModel)<br>    case carousel(CarouselModel)<br>    case grid(GridModel)<br>}</pre><p>The backend doesn’t tell the application:</p><blockquote><em>“Create this exact UIKit hierarchy.”</em></blockquote><p>Instead, it provides data that maps into a known set of supported capabilities.</p><p>This keeps the client architecture under control.</p><h3>Don’t Make the API Your UI Framework</h3><p>One anti-pattern I’ve seen conceptually is turning JSON into an entire UI programming language.</p><p>For example:</p><pre>{<br>  &quot;view&quot;: &quot;verticalStack&quot;,<br>  &quot;children&quot;: [<br>    {<br>      &quot;view&quot;: &quot;text&quot;,<br>      &quot;font&quot;: &quot;headline&quot;<br>    },<br>    {<br>      &quot;view&quot;: &quot;button&quot;,<br>      &quot;action&quot;: &quot;openProduct&quot;<br>    }<br>  ]<br>}</pre><p>At this point, the backend is effectively describing a UI framework.</p><p>Now you have two problems.</p><p>You have:</p><ol><li>UIKit/SwiftUI</li></ol><p>and:</p><p>2. Your own server-driven UI framework.</p><p>The second framework needs:</p><ul><li>versioning</li><li>testing</li><li>documentation</li><li>accessibility support</li><li>analytics</li><li>error handling</li><li>backward compatibility</li><li>rendering logic</li><li>That’s a significant engineering investment.</li></ul><h3>The Hidden Cost: Debugging</h3><p>Backend-driven UI can make debugging more complicated.</p><p>A developer might receive a bug report:</p><blockquote><em>“The home screen looks wrong.”</em></blockquote><p>The investigation may now involve:</p><pre>iOS Code<br>   ↓<br>API Response<br>   ↓<br>Remote Configuration<br>   ↓<br>Backend Logic<br>   ↓<br>Experiment Assignment<br>   ↓<br>User/Region<br>   ↓<br>App Version</pre><p>The problem may not exist in the iOS code at all.</p><p>Observability becomes extremely important.</p><p>Useful logging might include:</p><pre>App Version: 20.44<br>Configuration Version: 184<br>Region: PK<br>Experiment: Home_V2<br>Components: banner, carousel, grid</pre><p>Without this information, reproducing a remotely configured UI bug can become painful.</p><h3>Testing Becomes More Important</h3><p>Traditional UI testing might test:</p><pre>Given App Version X<br>When user opens Home<br>Then show Banner A</pre><p>With backend-driven UI, there may be many possible configurations.</p><p>You now need to test:</p><pre>Configuration A<br>Configuration B<br>Configuration C<br>Missing configuration<br>Invalid configuration<br>Old configuration<br>New configuration<br>Unknown component<br>Partial API response<br>Offline state</pre><p>The number of possible states can grow quickly.</p><p>This is one reason why flexibility has a cost.</p><h3>Backend-Driven UI Works Best Within a Contract</h3><p>A healthy system needs a strong contract between backend and client.</p><p>For example:</p><pre>Backend<br>   ↓<br>Supported Components<br>   ↓<br>Version Contract<br>   ↓<br>iOS Renderer</pre><p>The contract should define:</p><ul><li>supported component types</li><li>required fields</li><li>optional fields</li><li>minimum app versions</li><li>fallback behavior</li><li>navigation identifiers</li><li>asset requirements</li><li>experiment rules</li></ul><p>The client should also validate incoming data.</p><p>Think of the API as an external dependency — not as trusted local code.</p><h3>What Should the Backend Control?</h3><p>A useful rule is to divide responsibilities into three categories.</p><h3>Category 1 — Usually Safe for Backend Control</h3><p>These are things that change frequently:</p><ul><li>content</li><li>labels</li><li>banners</li><li>ordering</li><li>campaign configuration</li><li>feature availability</li><li>remote configuration</li><li>experiments</li></ul><h3>Category 2 — Backend + Client Cooperation</h3><p>These often need both sides:</p><ul><li>navigation destinations</li><li>deep-link parameters</li><li>feature flags</li><li>content types</li><li>dynamic sections</li><li>authentication-dependent screens</li></ul><p>The backend provides configuration.</p><p>The client validates and executes known behavior.</p><h3>Category 3 — Usually Better Owned by the Client</h3><p>These are tightly coupled to the platform:</p><ul><li>core navigation architecture</li><li>accessibility implementation</li><li>platform-specific interactions</li><li>complex animations</li><li>device capabilities</li><li>permissions</li><li>native media behavior</li><li>security-sensitive flows</li><li>The backend can provide data.</li></ul><p>The iOS application should retain control over how the platform capability is executed.</p><h3>The Hybrid Approach</h3><p>A practical architecture might look like this:</p><pre>               Backend<br>                   │<br>          ┌────────┴────────┐<br>          │                 │<br>      Content          Configuration<br>          │                 │<br>          └────────┬────────┘<br>                   ↓<br>              iOS Client<br>                   ↓<br>        Validate + Interpret<br>                   ↓<br>        Known Native Components<br>                   ↓<br>              UIKit/SwiftUI</pre><p>This gives the backend flexibility without making the application completely dependent on server-defined UI.</p><h3>The Golden Rule</h3><p>The most useful rule I’ve found when thinking about backend-driven UI is:</p><blockquote><strong><em>Make the backend flexible, but make the client predictable.</em></strong></blockquote><p>The server can decide:</p><pre>What content?<br>Which order?<br>Which campaign?<br>Which existing feature?<br>Which configuration?</pre><p>The client should decide:</p><pre>How should this capability behave?<br>How should it interact with iOS?<br>How should it fail?<br>How should it remain accessible?<br>How should it work offline?</pre><p>That separation creates a much healthier architecture.</p><h3>Final Thoughts</h3><p>Backend-driven UI isn’t inherently good or bad.</p><p>It is an architectural trade-off.</p><p>It can provide enormous flexibility for content-heavy applications, experimentation, campaigns, and remote configuration.</p><p>But flexibility introduces complexity.</p><p>The more responsibility you move to the backend, the more you need to think about:</p><ul><li>version compatibility</li><li>fallback behavior</li><li>testing</li><li>observability</li><li>offline behavior</li><li>accessibility</li><li>API contracts</li><li>App Store requirements</li><li>client/server ownership</li></ul><p>The goal shouldn’t be:</p><blockquote><strong><em>“Make everything dynamic.”</em></strong></blockquote><p>The goal should be:</p><blockquote><strong><em>“Make the right things dynamic.”</em></strong></blockquote><p>A strong iOS architecture doesn’t try to eliminate the backend’s role.</p><p>It defines a clear boundary between <strong>what the server controls and what the application owns</strong>.</p><p>And sometimes, keeping a piece of UI native isn’t a limitation.</p><p>It is an architectural decision.</p><h3>What’s your experience with Backend-Driven UI?</h3><p>Have you worked on an application where the backend controlled significant parts of the UI?</p><p>What boundaries did your team establish between backend configuration and native iOS behavior?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6a1c719817d4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encryption for Mobile Developers — Part 3]]></title>
            <link>https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-3-12705ad41a05?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/12705ad41a05</guid>
            <category><![CDATA[mobile-encryption]]></category>
            <category><![CDATA[swift-cryptography]]></category>
            <category><![CDATA[ios-security]]></category>
            <category><![CDATA[mobile-security-ios]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Mon, 17 Aug 2026 05:01:03 GMT</pubDate>
            <atom:updated>2026-08-17T05:01:03.302Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nXA7kpeubNmrekWeHUqYYw.png" /></figure><h3>CryptoKit, AES-GCM, ChaChaPoly, Keychain, Secure Enclave &amp; Practical Swift</h3><p>In <a href="https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-1-symmetric-encryption-asymmetric-encryption-and-hashing-b3a50d729d88"><strong>Part 1</strong></a>, we covered the fundamentals of cryptography:</p><ul><li>Symmetric Encryption</li><li>Asymmetric Encryption</li><li>Hashing</li><li>Encryption vs Hashing</li></ul><p>In <a href="https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-2-72cc5cc5159e?sharedUserId=sabihhida88"><strong>Part 2</strong></a>, we moved into real-world systems:</p><ul><li>Digital Signatures</li><li>HTTPS/TLS</li><li>WhatsApp End-to-End Encryption</li><li>Signal Protocol</li><li>Group Chat Encryption</li></ul><p>Now let’s bring those concepts into the <strong>iOS world</strong>.</p><p>As iOS developers, we usually shouldn’t implement cryptographic algorithms ourselves. Apple provides <strong>CryptoKit</strong> and security frameworks that give us APIs for hashing, encryption, authentication, digital signatures, key agreement, and secure key management. (<a href="https://developer.apple.com/documentation/cryptokit?utm_source=chatgpt.com">Apple Developer</a>)</p><h3>1. CryptoKit</h3><p><strong>CryptoKit</strong> is Apple’s framework for performing common cryptographic operations in Swift.</p><p>It provides APIs for:</p><ul><li>Hashing</li><li>Symmetric encryption</li><li>Message authentication</li><li>Digital signatures</li><li>Key agreement</li><li>Key generation</li></ul><p>Import it with:</p><pre>import CryptoKit</pre><p>For example, SHA-256:</p><pre>import CryptoKit<br><br>let message = Data(&quot;Hello World&quot;.utf8)<br><br>let hash = SHA256.hash(data: message)<br><br>print(hash)</pre><p>Conceptually:</p><pre>&quot;Hello World&quot;<br>      ↓<br>    SHA-256<br>      ↓<br> Hash / Digest</pre><p>You don’t need to implement SHA-256 yourself.</p><blockquote><strong><em>Use established cryptographic libraries instead of implementing cryptographic algorithms yourself.</em></strong></blockquote><h3>2. Hashing with CryptoKit</h3><p>Suppose we want to calculate the SHA-256 hash of some data:</p><pre>import CryptoKit</pre><pre>let data = Data(&quot;Hello World&quot;.utf8)</pre><pre>let digest = SHA256.hash(data: data)</pre><pre>let hash = digest<br>    .map { String(format: &quot;%02x&quot;, $0) }<br>    .joined()</pre><pre>print(hash)</pre><p>Hashing is useful for things such as:</p><ul><li>File integrity verification</li><li>Data fingerprints</li><li>Detecting changes</li><li>Message authentication when combined with a secret through HMAC</li></ul><p>But remember:</p><blockquote><strong><em>Hashing is not encryption.</em></strong></blockquote><p>A hash isn’t something you decrypt to recover the original data.</p><h3>3. AES-GCM</h3><p>Now let’s look at actual encryption.</p><p><strong>AES</strong> is a symmetric encryption algorithm, and <strong>GCM (Galois/Counter Mode)</strong> is an authenticated encryption mode available through CryptoKit. (<a href="https://developer.apple.com/documentation/cryptokit/aes?changes=l_1&amp;utm_source=chatgpt.com">Apple Developer</a>)</p><pre>Secret Key<br>    ↓<br>AES-GCM<br>    ↓<br>Ciphertext + Authentication Tag</pre><p>CryptoKit can generate a random symmetric key:</p><pre>let key = SymmetricKey(size: .bits256)</pre><p>Apple’s SymmetricKey API supports generating random symmetric keys and using them with AES-GCM or ChaChaPoly. (<a href="https://developer.apple.com/documentation/cryptokit/symmetrickey?utm_source=chatgpt.com">Apple Developer</a>)</p><h3>Encrypting Data</h3><pre>import CryptoKit<br><br>let key = SymmetricKey(size: .bits256)<br><br>let message = Data(&quot;Hello World&quot;.utf8)<br><br>let sealedBox = try AES.GCM.seal(<br>    message,<br>    using: key<br>)<br>let encryptedData = sealedBox.combined!</pre><p>Conceptually:</p><pre>&quot;Hello World&quot;<br>      ↓<br> AES-GCM + Key<br>      ↓<br>Encrypted Data</pre><p>AES.GCM.SealedBox contains the information needed to later authenticate and decrypt the encrypted message, including the nonce, ciphertext, and authentication tag. (<a href="https://developer.apple.com/documentation/cryptokit/aes/gcm?changes=_5&amp;utm_source=chatgpt.com">Apple Developer</a>)</p><h3>4. Decrypting AES-GCM</h3><p>The receiver needs the same symmetric key:</p><pre>let sealedBox = try AES.GCM.SealedBox(<br>    combined: encryptedData<br>)<br>let decryptedData = try AES.GCM.open(<br>    sealedBox,<br>    using: key<br>)<br>let message = String(<br>    data: decryptedData,<br>    encoding: .utf8<br>)<br>print(message ?? &quot;&quot;)</pre><p>Output:</p><pre>Hello World</pre><p>The important thing about AES-GCM is that it provides both:</p><p><strong>Confidentiality + Authentication</strong></p><p>If the ciphertext has been modified, authentication fails and decryption throws an error. (<a href="https://developer.apple.com/documentation/cryptokit/aes/gcm?changes=_5&amp;utm_source=chatgpt.com">Apple Developer</a>)</p><h3>5. What Is a Nonce?</h3><p>When using AES-GCM, you’ll encounter a <strong>nonce</strong>.</p><p>Nonce means:</p><blockquote><strong><em>Number used once</em></strong></blockquote><p>CryptoKit can generate one automatically:</p><pre>let sealedBox = try AES.GCM.seal(<br>    message,<br>    using: key<br>)</pre><p>Or you can explicitly create one:</p><pre>let nonce = AES.GCM.Nonce()<br><br>let sealedBox = try AES.GCM.seal(<br>    message,<br>    using: key,<br>    nonce: nonce<br>)</pre><h3>Important rule</h3><blockquote><strong><em>Never reuse the same nonce with the same encryption key.</em></strong></blockquote><p>Nonce uniqueness is critical for authenticated encryption schemes such as AES-GCM. (<a href="https://developer.apple.com/documentation/cryptokit/aes/gcm?changes=_5&amp;utm_source=chatgpt.com">Apple Developer</a>)</p><p>In real applications, don’t invent your own nonce-generation scheme unless the protocol specifically requires it.</p><h3>6. ChaChaPoly</h3><p>CryptoKit also provides:</p><pre>ChaChaPoly</pre><p>It implements <strong>ChaCha20-Poly1305</strong>, another authenticated encryption construction. (<a href="https://developer.apple.com/documentation/cryptokit/chachapoly?utm_source=chatgpt.com">Apple Developer</a>)</p><p>Example:</p><pre>import CryptoKit<br><br>let key = SymmetricKey(size: .bits256)<br>let message = Data(&quot;Hello World&quot;.utf8)<br>let sealedBox = try ChaChaPoly.seal(<br>    message,<br>    using: key<br>)</pre><p>And decryption:</p><pre>let decryptedData = try ChaChaPoly.open(<br>    sealedBox,<br>    using: key<br>)</pre><p>Like AES-GCM, ChaChaPoly provides encryption together with authentication. (<a href="https://developer.apple.com/documentation/cryptokit/chachapoly?utm_source=chatgpt.com">Apple Developer</a>)</p><p>You shouldn’t choose between AES-GCM and ChaChaPoly simply because one “sounds more secure.”</p><p>The appropriate choice depends on your protocol, compatibility, performance requirements, and existing system design.</p><h3>7. Where Should We Store Encryption Keys?</h3><p>This is arguably more important than choosing AES vs ChaChaPoly.</p><p>Imagine:</p><pre>let key = SymmetricKey(size: .bits256)</pre><p>Where should that key live?</p><p>Definitely don’t do this:</p><pre>❌ Source Code<br>❌ UserDefaults<br>❌ Plain-text JSON<br>❌ Plain-text File</pre><p>For persistent sensitive secrets, iOS provides the <strong>Keychain</strong>.</p><h3>8. Keychain</h3><p>The Keychain is designed for protected storage of sensitive information such as:</p><ul><li>Passwords</li><li>Authentication tokens</li><li>Credentials</li><li>Other secret data</li></ul><p>Conceptually:</p><pre>Application<br>     ↓<br>  Keychain<br>     ↓<br>Sensitive Secret</pre><p>A simplified example:</p><pre>let password = Data(&quot;my-secret&quot;.utf8)</pre><pre>let query: [String: Any] = [<br>    kSecClass as String: kSecClassGenericPassword,<br>    kSecAttrAccount as String: &quot;myAccount&quot;,<br>    kSecValueData as String: password,<br>    kSecAttrAccessible as String:<br>        kSecAttrAccessibleWhenUnlockedThisDeviceOnly<br>]</pre><pre>SecItemAdd(<br>    query as CFDictionary,<br>    nil<br>)</pre><h3>Why kSecAttrAccessible matters</h3><p>Keychain items can have different accessibility rules depending on the device state.</p><p>For example:</p><pre>kSecAttrAccessibleWhenUnlockedThisDeviceOnly</pre><p>means the item is accessible only while the device is unlocked and is restricted to that device. Apple recommends choosing the <strong>most restrictive accessibility level that satisfies the application’s requirements</strong>. (<a href="https://developer.apple.com/documentation/security/ksecattraccessible?changes=_9&amp;utm_source=chatgpt.com">Apple Developer</a>)</p><p>In production code, Keychain operations should normally be wrapped inside a dedicated abstraction rather than scattered throughout the application.</p><h3>9. Keychain vs UserDefaults</h3><p>This is a common interview question.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fSWpXUXD2aa7xg3ooOfHOg.png" /></figure><p>For example, avoid storing sensitive authentication credentials like this:</p><pre>UserDefaults.standard.set(<br>    token,<br>    forKey: &quot;authToken&quot;<br>)</pre><p>Use an appropriate secure storage mechanism such as Keychain instead.</p><h3>10. What Is the Secure Enclave?</h3><p>The <strong>Secure Enclave</strong> is a hardware-backed security component available on supported Apple devices.</p><p>But there is an important limitation:</p><blockquote><strong><em>Secure Enclave is not a general-purpose vault for arbitrary cryptographic keys.</em></strong></blockquote><p>With CryptoKit, Secure Enclave specifically provides support for <strong>P-256 elliptic-curve signing and key-agreement keys</strong>. (<a href="https://developer.apple.com/documentation/cryptokit/secureenclave/p256?changes=_2&amp;utm_source=chatgpt.com">Apple Developer</a>)</p><p>Conceptually:</p><pre>iOS App<br>   │<br>   │ Request cryptographic operation<br>   ▼<br>Secure Enclave<br>   │<br>   │ P-256 private key<br>   ▼<br>Cryptographic Result</pre><p>For example:</p><pre>import CryptoKit<br><br>let privateKey =<br>    try SecureEnclave.P256.Signing.PrivateKey()</pre><p>The private key is protected by the Secure Enclave rather than being exposed to your application as ordinary raw private-key material.</p><h3>Important interview question</h3><p><strong>Can you store an AES-256 key directly inside the Secure Enclave?</strong></p><blockquote><strong><em>No.</em></strong><em> CryptoKit’s Secure Enclave support isn’t a general-purpose symmetric-key storage mechanism. Its documented CryptoKit support includes P-256 signing and key agreement. (</em><a href="https://developer.apple.com/documentation/cryptokit/secureenclave/p256?changes=_2&amp;utm_source=chatgpt.com"><em>Apple Developer</em></a><em>)</em></blockquote><p>So:</p><pre>AES-256 Key<br>     ↓<br>Secure Enclave ❌</pre><p>while:</p><pre>P-256 Private Key<br>       ↓<br>Secure Enclave ✅</pre><p>For symmetric secrets such as AES keys, an appropriate <strong>Keychain-based design</strong> is generally the relevant approach.</p><h3>11. Keychain vs Secure Enclave</h3><p>These are often confused.</p><h3>Keychain</h3><p>Think:</p><blockquote><strong><em>Secure storage for sensitive data.</em></strong></blockquote><pre>Token<br>Password<br>Credential<br>Secret</pre><h3>Secure Enclave</h3><p>Think:</p><blockquote><strong><em>Hardware-backed protection for supported cryptographic keys and operations.</em></strong></blockquote><pre>P-256 Private Key<br>       ↓<br>Secure Enclave<br>       ↓<br>Sign / Key Agreement</pre><p>They can work together.</p><pre>iOS App<br>                   │<br>          ┌────────┴────────┐<br>          ▼                 ▼<br>      Keychain        Secure Enclave<br>          │                 │<br>   Tokens / Secrets    P-256 Private Key</pre><h3>12. Digital Signatures on iOS</h3><p>CryptoKit supports digital signatures.</p><p>For example:</p><pre>import CryptoKit<br><br>let privateKey = P256.Signing.PrivateKey()<br><br>let message = Data(&quot;Hello World&quot;.utf8)<br><br>let signature = try privateKey.signature(<br>    for: message<br>)</pre><p>The public key can verify the signature:</p><pre>let publicKey = privateKey.publicKey<br><br>let isValid = publicKey.isValidSignature(<br>    signature,<br>    for: message<br>)<br>print(isValid)</pre><p>The flow is:</p><pre>Message<br>   ↓<br>Private Key<br>   ↓<br>Digital Signature<br>   ↓<br>Public Key<br>   ↓<br>Verify</pre><p>Remember:</p><blockquote><strong><em>Digital signatures provide authenticity and integrity, not confidentiality.</em></strong></blockquote><h3>13. Key Agreement</h3><p>CryptoKit also supports key agreement.</p><p>For example:</p><pre>Curve25519.KeyAgreement</pre><p>Two parties can use their private/public key pairs to derive shared secret material.</p><p>Conceptually:</p><pre>Alice                         Bob</pre><pre>Private Key                   Private Key<br>    │                             │<br>Public Key                    Public Key<br>    │                             │<br>    └────── Key Agreement ────────┘<br>                  ↓<br>          Shared Secret</pre><p>CryptoKit’s SharedSecret can then be used to derive symmetric cryptographic keys. (<a href="https://developer.apple.com/documentation/cryptokit?utm_source=chatgpt.com">Apple Developer</a>)</p><p>This is one of the foundations behind secure communication protocols.</p><h3>14. Encryption Is Only One Part of Security</h3><p>A common mistake is to think:</p><blockquote><em>“I’ll encrypt the data, so my app is secure.”</em></blockquote><p>Not necessarily.</p><p>A secure design also needs to consider:</p><pre>            Application Security<br>                        │<br>       ┌────────────────┼────────────────┐<br>       │                │                │<br>       ▼                ▼                ▼<br>   Encryption      Key Management    Authentication<br>       │                │                │<br>       └────────────────┼────────────────┘<br>                        │<br>              Secure Storage<br>                        │<br>                        ▼<br>                  Network Security</pre><p>For example:</p><pre>AES-256<br>   +<br>Hardcoded Key<br>   =<br>Bad Security</pre><p>A strong encryption algorithm cannot compensate for poor key management.</p><h3>15. Example: Secure API Token Storage</h3><p>Imagine your application receives:</p><pre>access_token = &quot;abc123...&quot;</pre><p>A poor implementation:</p><pre>UserDefaults.standard.set(<br>    token,<br>    forKey: &quot;accessToken&quot;<br>)</pre><p>A better architecture:</p><pre>API<br> ↓<br>Authentication Token<br> ↓<br>Keychain<br> ↓<br>Application</pre><p>The important lesson isn’t simply:</p><blockquote><strong><em>“Always use Keychain.”</em></strong></blockquote><p>It’s:</p><blockquote><strong><em>Choose storage based on the sensitivity and lifecycle of the data.</em></strong></blockquote><h3>16. Example: Encrypting Sensitive Local Data</h3><p>Suppose your app stores sensitive information locally.</p><p>A conceptual design could be:</p><pre>Sensitive Data<br>      ↓<br>   AES-GCM<br>      ↓<br>Encrypted Data<br>      ↓<br>Local Storage</pre><p>The encryption key should not simply sit next to the encrypted data in plaintext.</p><p>Instead:</p><pre>Encrypted Data<br>     ↓<br>Database / File</pre><pre>Encryption Key<br>     ↓<br>Secure Key Storage</pre><p>This separation is an important part of key management.</p><h3>17. File Integrity Verification</h3><p>Hashing is useful when you want to determine whether a file has changed.</p><p>Suppose a publisher provides:</p><pre>MySDK.zip</pre><p>The publisher calculates:</p><pre>MySDK.zip<br>    ↓<br> SHA-256<br>    ↓<br>ABC123...</pre><p>The expected hash is published through a trusted channel.</p><p>You download the file and calculate the hash again:</p><pre>Downloaded MySDK.zip<br>       ↓<br>    SHA-256<br>       ↓<br>ABC123...</pre><p>Then:</p><pre>Published Hash<br>      ==<br>Downloaded Hash</pre><p>✅ The downloaded file matches the expected content.</p><p>If:</p><pre>Published Hash<br>      !=<br>Downloaded Hash</pre><p>❌ The downloaded content doesn’t match.</p><p>But there’s an important limitation:</p><blockquote><strong><em>A hash alone doesn’t prove who created the file.</em></strong></blockquote><p>If authenticity matters, the expected hash can itself be authenticated using a <strong>digital signature</strong>.</p><h3>18. Encoding vs Encryption</h3><p>Another common interview question:</p><h3>Encoding</h3><p>Changes the representation of data.</p><pre>Hello<br>  ↓<br>Base64<br>  ↓<br>SGVsbG8=</pre><p>Anyone who knows Base64 can decode it.</p><h3>Encryption</h3><p>Protects confidentiality.</p><pre>Hello<br>  ↓<br>AES + Key<br>  ↓<br>Encrypted Data</pre><p>The appropriate decryption key is required to recover the plaintext.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*w4w79csrzugwszGLyOkSgw.png" /></figure><blockquote><strong><em>Encoding changes data. Encryption protects data.</em></strong></blockquote><h3>19. Certificate Pinning</h3><p>You may have heard:</p><blockquote><strong><em>“We should use certificate pinning for API security.”</em></strong></blockquote><p>Certificate pinning adds an application-level restriction on which server certificate or public key the app accepts.</p><p>Conceptually:</p><pre>App<br> │<br> │ HTTPS<br> ▼<br>Server Certificate<br> │<br> ▼<br>Expected Identity?<br> │<br> ├── Yes → Continue<br> │<br> └── No  → Reject</pre><p>However, certificate pinning isn’t automatically required for every iOS application.</p><p>It adds operational complexity, especially around certificate or key rotation.</p><p>The important interview distinction is:</p><blockquote><strong><em>TLS certificate validation is the normal foundation. Certificate pinning adds an additional trust restriction and must be managed carefully.</em></strong></blockquote><h3>20. Common iOS Security Mistakes</h3><h3>❌ Hardcoding secrets</h3><pre>let apiKey = &quot;super-secret-key&quot;</pre><p>Anything shipped inside the application should be treated as potentially discoverable.</p><h3>❌ Storing sensitive tokens in UserDefaults</h3><pre>UserDefaults.standard.set(<br>    token,<br>    forKey: &quot;token&quot;<br>)</pre><p>Use an appropriate secure storage mechanism for sensitive credentials.</p><h3>❌ Implementing your own encryption</h3><pre>MyCustomEncryption()</pre><p>Don’t invent cryptography.</p><p>Use established algorithms, protocols, and trusted platform APIs.</p><h3>❌ Reusing AES-GCM nonces</h3><p>Nonce reuse with the same key can seriously compromise the security guarantees of AES-GCM.</p><h3>❌ Confusing Base64 with encryption</h3><pre>Base64 ≠ Encryption</pre><p>Base64 provides encoding, not confidentiality.</p><h3>❌ Encrypting without authentication</h3><p>Encryption alone doesn’t necessarily detect whether ciphertext has been modified.</p><p>Prefer authenticated encryption constructions such as:</p><pre>AES-GCM<br>ChaChaPoly</pre><p>when appropriate. (<a href="https://developer.apple.com/documentation/cryptokit/aes/gcm?changes=_5&amp;utm_source=chatgpt.com">Apple Developer</a>)</p><h3>21. Practical iOS Security Architecture</h3><p>A typical iOS application might look conceptually like:</p><pre>            iOS Application<br>                       │<br>          ┌────────────┼────────────┐<br>          │            │            │<br>          ▼            ▼            ▼<br>       CryptoKit    Keychain    URLSession<br>          │            │            │<br>          │            │            ▼<br>          │            │          HTTPS<br>          │            │            │<br>          ▼            ▼            ▼<br>     Encryption     Secrets      Backend<br>     / Signing      / Keys</pre><p>Each component has a different responsibility.</p><h3>22. What Should an iOS Developer Remember?</h3><p>You don’t need to memorize every CryptoKit API.</p><p>Instead, remember the decision-making process.</p><h3>Need to hash data?</h3><pre>SHA256</pre><h3>Need symmetric authenticated encryption?</h3><pre>AES.GCM<br>ChaChaPoly</pre><h3>Need digital signatures?</h3><pre>P256.Signing</pre><h3>Need key agreement?</h3><pre>Curve25519.KeyAgreement</pre><h3>Need to securely store credentials?</h3><pre>Keychain</pre><h3>Need hardware-backed P-256 key protection?</h3><pre>SecureEnclave.P256</pre><h3>Need secure network communication?</h3><pre>HTTPS / TLS</pre><h3>23. Interview Questions</h3><h3>Q1. What is CryptoKit?</h3><blockquote><em>Apple’s framework for common cryptographic operations including hashing, encryption, authentication, digital signatures, and key agreement.</em></blockquote><h3>Q2. Where should you store an authentication token?</h3><blockquote><em>In the Keychain rather than UserDefaults or a plain file.</em></blockquote><h3>Q3. What’s the difference between Keychain and Secure Enclave?</h3><blockquote><em>Keychain provides protected storage for sensitive data. Secure Enclave provides hardware-backed protection for supported cryptographic keys and operations, such as P-256 signing and key agreement.</em></blockquote><h3>Q4. Can you store an AES key directly in the Secure Enclave?</h3><blockquote><em>No. CryptoKit’s Secure Enclave support is not a general-purpose AES-key vault. Its documented CryptoKit support includes P-256 signing and key agreement. (</em><a href="https://developer.apple.com/documentation/cryptokit/secureenclave/p256?changes=_2&amp;utm_source=chatgpt.com"><em>Apple Developer</em></a><em>)</em></blockquote><h3>Q5. AES-GCM vs AES?</h3><blockquote><em>AES is the encryption algorithm; GCM is an authenticated encryption mode used with AES.</em></blockquote><h3>Q6. Why is AES-GCM nonce reuse dangerous?</h3><blockquote><em>Nonces must be unique for encryption operations with a given key. Reuse can compromise the security guarantees of the construction. (</em><a href="https://developer.apple.com/documentation/cryptokit/aes/gcm?changes=_5&amp;utm_source=chatgpt.com"><em>Apple Developer</em></a><em>)</em></blockquote><h3>Q7. Is Base64 encryption?</h3><blockquote><em>No. Base64 is encoding and provides no confidentiality.</em></blockquote><h3>Q8. Why shouldn’t we implement our own encryption?</h3><blockquote><em>Cryptography is extremely easy to get subtly wrong. Established libraries, algorithms, and protocols have undergone extensive analysis and testing.</em></blockquote><h3>Q9. Does HTTPS mean API data is end-to-end encrypted?</h3><blockquote><em>No. HTTPS protects the connection between the client and server. The server can normally access the application data after TLS termination. E2EE is a different architecture.</em></blockquote><h3>Q10. Why does kSecAttrAccessible matter?</h3><blockquote><em>It controls when a Keychain item can be accessed based on the device state. The right accessibility level depends on the application’s requirements, and Apple recommends using the most restrictive option that still meets those requirements. (</em><a href="https://developer.apple.com/documentation/security/ksecattraccessible?changes=_9&amp;utm_source=chatgpt.com"><em>Apple Developer</em></a><em>)</em></blockquote><h3>24. Final Mental Model</h3><p>After all three parts, you should have this mental model:</p><pre>                  CRYPTOGRAPHY<br>                         │<br>        ┌────────────────┼────────────────┐<br>        │                │                │<br>        ▼                ▼                ▼<br>     Hashing        Encryption       Signatures<br>        │                │                │<br>        ▼                ▼                ▼<br>    Integrity       Confidentiality   Authenticity<br>                         │<br>              ┌──────────┴──────────┐<br>              │                     │<br>              ▼                     ▼<br>          Symmetric             Asymmetric<br>              │                     │<br>              ▼                     ▼<br>          AES-GCM              Key Agreement<br>          ChaChaPoly           Signatures<br>              │                     │<br>              └──────────┬──────────┘<br>                         ▼<br>                    Secure Systems<br>                         │<br>          ┌──────────────┼──────────────┐<br>          ▼              ▼              ▼<br>        TLS          Keychain      Secure Enclave<br>          │<br>          ▼<br>      iOS Apps</pre><p>The biggest lesson isn’t:</p><blockquote><strong><em>“Learn every encryption algorithm.”</em></strong></blockquote><p>It’s:</p><blockquote><strong><em>Understand what security problem you’re solving, choose the appropriate primitive or protocol, and protect the keys properly.</em></strong></blockquote><p>For an iOS developer, that means understanding not only <strong>how to encrypt data</strong>, but also <strong>how keys are generated, stored, accessed, and protected</strong>.</p><h3>Conclusion</h3><p>The series has now moved through three levels.</p><h3>Part 1 — Fundamentals</h3><blockquote><strong><em>What are encryption and hashing?</em></strong></blockquote><h3>Part 2 — Real-World Systems</h3><blockquote><strong><em>How are these concepts used in HTTPS and secure messaging?</em></strong></blockquote><h3>Part 3 — iOS Security</h3><blockquote><strong><em>How do we apply these concepts safely using Apple’s security APIs?</em></strong></blockquote><p>The most important principle is simple:</p><blockquote><em>🔐 </em><strong><em>Don’t invent cryptography. Use proven algorithms, established protocols, and secure platform APIs — and treat key management as seriously as the encryption itself.</em></strong></blockquote><h3>The Encryption Series</h3><p><a href="https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-1-symmetric-encryption-asymmetric-encryption-and-hashing-b3a50d729d88"><strong>Part 1 — Fundamentals</strong><br></a>Symmetric Encryption • Asymmetric Encryption • Hashing</p><p><a href="https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-2-72cc5cc5159e"><strong>Part 2 — Real-World Systems</strong><br></a>Digital Signatures • HTTPS/TLS • WhatsApp E2EE • Signal Protocol</p><p><strong>Part 3 — iOS Security</strong><br>CryptoKit • AES-GCM • ChaChaPoly • Keychain • Secure Enclave • Swift</p><p><em>Note: The Swift snippets in this article are intentionally simplified for learning. In production code, handle thrown errors appropriately with </em><em>do/catch, </em><em>throws, or another suitable error-handling strategy.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=12705ad41a05" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encryption for Mobile Developers — Part 2]]></title>
            <link>https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-2-72cc5cc5159e?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/72cc5cc5159e</guid>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[mobile-security]]></category>
            <category><![CDATA[cybersecurity]]></category>
            <category><![CDATA[end-to-end-encryption]]></category>
            <category><![CDATA[ios-security]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Wed, 12 Aug 2026 12:46:40 GMT</pubDate>
            <atom:updated>2026-08-12T12:46:40.371Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zy4c1gd-QKpj3wiAeVQgUg.png" /></figure><p>In <a href="https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-1-symmetric-encryption-asymmetric-encryption-and-hashing-b3a50d729d88?sharedUserId=sabihhida88"><strong>Part 1: Symmetric Encryption, Asymmetric Encryption</strong></a>, we covered the fundamentals of cryptography:</p><ul><li>Symmetric Encryption</li><li>Asymmetric Encryption</li><li>Hashing</li></ul><p>Now let’s see how these concepts come together in real-world systems.</p><p>How does HTTPS know that you’re talking to the correct server?</p><p>How does a digital signature prove that data came from the expected source?</p><p>And how can WhatsApp protect a message even though that message travels through its servers?</p><p>Let’s break it down.</p><h3>1. Digital Signatures</h3><p>Encryption answers:</p><blockquote><strong><em>“How do I keep this data secret?”</em></strong></blockquote><p>But sometimes we need to answer a different question:</p><blockquote><strong><em>“Who sent this data, and was it modified?”</em></strong></blockquote><p>That’s where <strong>Digital Signatures</strong> come in.</p><p>A digital signature is a cryptographic mechanism used to verify the <strong>authenticity and integrity</strong> of data.</p><p>The sender signs data using their <strong>private key</strong>, and the receiver verifies the signature using the sender’s <strong>public key</strong>.</p><pre>Message<br>   ↓<br>Hash<br>   ↓<br>Sender&#39;s Private Key<br>   ↓<br>Digital Signature</pre><p>The receiver then:</p><pre>Digital Signature<br>        ↓<br>Sender&#39;s Public Key<br>        ↓<br>      Verify</pre><p>If verification succeeds:</p><p>✅ The signature is valid<br>✅ The data has not been modified<br>✅ The signature corresponds to the expected signing key</p><h3>Easy way to remember</h3><pre>Encryption:<br>Public Key → Encrypt<br>Private Key → Decrypt</pre><pre>Digital Signature:<br>Private Key → Sign<br>Public Key → Verify</pre><blockquote><em>🔐 </em><strong><em>Encryption = Keep it secret</em></strong><em><br>✍️ </em><strong><em>Digital Signature = Prove it’s authentic</em></strong></blockquote><p>Digital signatures are widely used in <strong>TLS certificates, software/code signing, and secure communication protocols</strong>.</p><h3>2. HTTPS / TLS Handshake</h3><p>When your iOS application communicates with an API:</p><pre>iPhone App<br>    ↓<br>   HTTPS<br>    ↓<br>Backend Server</pre><p>HTTPS uses <strong>TLS (Transport Layer Security)</strong> to establish a secure communication channel.</p><p>A simplified TLS 1.3 handshake looks like this:</p><pre>Client                         Server</pre><pre>  │──── Client Hello ──────────►│<br>  │     + Key Share             │<br>  │                             │<br>  │◄──── Server Hello ──────────│<br>  │     + Key Share             │<br>  │     + Certificate           │<br>  │                             │<br>  │   Verify Certificate        │<br>  │  against trusted CAs        │<br>  │                             │<br>  │════ Encrypted Data ═════════│</pre><p>The actual TLS handshake contains more details, but the important concepts are:ClientHello</p><p>The client sends information such as:</p><ul><li>Supported TLS versions</li><li>Supported cryptographic options</li><li>Key-share information</li><li>Random handshake data</li></ul><h3>Server Hello</h3><p>The server selects the appropriate parameters and provides its certificate and key-share information.</p><h3>Certificate Verification</h3><p>This is a critical security step.</p><p>The client verifies the server’s certificate against its <strong>trusted certificate authority (CA) chain</strong> and checks that the certificate is valid for the server it is connecting to.</p><p>This helps prevent a <strong>man-in-the-middle attacker</strong> from impersonating the server.</p><h3>Key Establishment</h3><p>TLS uses the handshake’s key-exchange material to derive shared symmetric traffic keys.</p><p>Then:</p><pre>TLS Handshake<br>      ↓<br>Shared Traffic Keys<br>      ↓<br>Symmetric Encryption<br>      ↓<br>Application Data</pre><p>This is why TLS is a good example of <strong>hybrid cryptography</strong>.</p><blockquote><strong><em>Asymmetric/public-key cryptography helps with authentication and key establishment, while symmetric cryptography protects the actual application data efficiently.</em></strong></blockquote><h3>3. WhatsApp End-to-End Encryption</h3><p>HTTPS protects communication between:</p><pre>App ↔ Server</pre><p>But <strong>End-to-End Encryption (E2EE)</strong> has a different goal.</p><p>It protects message content between:</p><pre>Sender ↔ Receiver</pre><p>Conceptually:</p><pre>Alice<br>  │<br>  │ Encrypt<br>  ▼<br>Ciphertext<br>  │<br>  ▼<br>WhatsApp Server<br>  │<br>  │ Forward<br>  ▼<br>Bob<br>  │<br>  │ Decrypt<br>  ▼<br>Message</pre><p>The server can deliver the encrypted message without needing access to the plaintext message itself.</p><p>WhatsApp’s end-to-end encrypted messaging uses the <strong>Signal Protocol as its cryptographic foundation</strong>.</p><h3>4. Signal Protocol Explained</h3><p>The Signal Protocol is not a single encryption algorithm.</p><p>It is a collection of cryptographic mechanisms designed for secure messaging.</p><p>Two important concepts are:</p><h3>X3DH</h3><p><strong>Extended Triple Diffie-Hellman (X3DH)</strong> is designed to establish initial shared secret material, including scenarios where the recipient may be offline.</p><p>Conceptually:</p><pre>Alice<br>  │<br>  │ Bob&#39;s public key material<br>  ▼<br>Key Agreement<br>  │<br>  ▼<br>Shared Secret</pre><p>The recipient can publish appropriate public key/prekey material ahead of time so another user can initiate a secure session without requiring the recipient to be online at that exact moment.</p><h3>Double Ratchet</h3><p>Once a secure session exists, the protocol continuously evolves its cryptographic state.</p><p>Conceptually:</p><pre>Key 1<br>  ↓<br>Key 2<br>  ↓<br>Key 3<br>  ↓<br>Key 4<br>  ↓<br>Key 5</pre><p>The important idea is:</p><blockquote><strong><em>Don’t use one permanent encryption key for every message.</em></strong></blockquote><p>The Double Ratchet derives fresh message-key material as the conversation progresses.</p><p>This contributes to important security properties such as <strong>forward secrecy</strong>.</p><h3>5. WhatsApp Message Flow</h3><p>Suppose Alice sends:</p><pre>&quot;Hey Bob!&quot;</pre><p>A simplified flow looks like this:</p><pre>Alice&#39;s Device<br>      │<br>      ▼<br>Double Ratchet<br>      │<br>      ▼<br>Fresh Message Key<br>      │<br>      ▼<br>   Encryption<br>      │<br>      ▼<br>   Ciphertext<br>      │<br>      ▼<br>WhatsApp Server<br>      │<br>      │ Forward<br>      ▼<br> Bob&#39;s Device<br>      │<br>      ▼<br>Double Ratchet<br>      │<br>      ▼<br>Message Key<br>      │<br>      ▼<br>   Decryption<br>      │<br>      ▼<br> &quot;Hey Bob!&quot;</pre><p>The important point is that the <strong>message key is not one permanent key</strong>.</p><p>It is derived from the evolving cryptographic state of the Double Ratchet.</p><p>The server primarily handles the <strong>delivery of encrypted data</strong> rather than needing the plaintext message.</p><h3>6. What Does E2EE Protect — and What Doesn’t It?</h3><p>This is an important interview question.</p><h3>E2EE protects:</h3><pre>Message Content<br>       ↓<br>Protected between endpoints</pre><p>But E2EE does <strong>not necessarily hide all metadata</strong>.</p><p>Depending on the system, the service may still have access to information such as:</p><ul><li>Sender and recipient information</li><li>Message timestamps</li><li>Account information</li><li>Device information</li><li>Delivery information</li><li>Group membership</li></ul><p>So remember:</p><blockquote><strong><em>E2EE protects message content, not necessarily all metadata surrounding the message.</em></strong></blockquote><p>This is an important distinction.</p><h3>7. What About Group Chats?</h3><p>Group messaging introduces another challenge.</p><p>Imagine:</p><pre>Alice<br> ├── Bob<br> ├── Charlie<br> └── David</pre><p>If Alice individually encrypted every message for every participant, the amount of encryption work could increase significantly as the group grows.</p><p>Signal-style group messaging uses mechanisms such as <strong>Sender Keys</strong> to make encrypted group communication more scalable.</p><p>Conceptually:</p><pre>              Alice<br>                │<br>          Group Encryption<br>                │<br>       ┌────────┼────────┐<br>       ▼        ▼        ▼<br>      Bob    Charlie   David</pre><p>The goal is to maintain strong end-to-end security while keeping group messaging efficient.</p><p>The exact implementation is more complex than this simplified diagram, but the important system-design idea is:</p><blockquote><strong><em>Group encryption must balance security, key management, and scalability.</em></strong></blockquote><h3>HTTPS vs End-to-End Encryption</h3><p>This is one of the most important distinctions for interviews.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cK2K4mh_z63GqzbporR36g.png" /></figure><p>They are <strong>not competing technologies</strong>.</p><p>A messaging application can use both:</p><pre>End-to-End Encryption<br><br>Alice ───────────────────────── Bob<br>  │                                │<br>  └────────── HTTPS/TLS ───────────┘<br>                  │<br>                Server</pre><p>For example:</p><ul><li><strong>E2EE</strong> protects the message content.</li><li><strong>TLS</strong> protects the network connection between each device and the service.</li></ul><h3>The Big Picture</h3><p>Now we can connect everything from Part 1 and Part 2:</p><pre>Hashing<br>   ↓<br>Integrity / Fingerprint</pre><pre>Digital Signature<br>   ↓<br>Authentication / Integrity</pre><pre>Asymmetric Cryptography<br>   ↓<br>Authentication / Key Agreement</pre><pre>Key Derivation<br>   ↓<br>Generate Cryptographic Keys</pre><pre>Symmetric Encryption<br>   ↓<br>Encrypt Actual Data</pre><pre>TLS<br>   ↓<br>Secure Network Channel</pre><pre>E2EE<br>   ↓<br>Protect Message Content</pre><p>Each technique solves a different problem.</p><p>That’s why modern security systems combine them rather than relying on a single algorithm.</p><h3>Interview Takeaways</h3><p>If you’re preparing for an iOS interview, remember these six points:</p><h3>1. What is a Digital Signature?</h3><blockquote><em>A mechanism that allows a receiver to verify the authenticity and integrity of data using the sender’s public key.</em></blockquote><h3>2. Why does HTTPS use symmetric encryption for data?</h3><blockquote><em>Because symmetric encryption is much more efficient for encrypting large amounts of application data.</em></blockquote><h3>3. What does the TLS certificate do?</h3><blockquote><em>It binds a public key to an identity and is authenticated through a certificate authority chain.</em></blockquote><h3>4. What is E2EE?</h3><blockquote><em>Encryption where the message content is protected between the communicating endpoints rather than being exposed to intermediary infrastructure.</em></blockquote><h3>5. Why does the Signal Protocol use ratcheting?</h3><blockquote><em>To continuously evolve cryptographic keys and provide stronger protection against key compromise, including forward secrecy.</em></blockquote><h3>6. Does E2EE hide everything?</h3><blockquote><em>No. E2EE protects message content, but metadata such as timing, identities, device information, or group information may still be exposed depending on the system.</em></blockquote><h3>Final Thought</h3><p>You don’t need to memorize every cryptographic algorithm to understand secure systems.</p><p>Instead, remember <strong>what each mechanism is responsible for</strong>:</p><pre>Digital Signature<br>       ↓<br>&quot;Who signed this?&quot;</pre><pre>TLS<br>       ↓<br>&quot;Am I securely communicating with this server?&quot;</pre><pre>Key Agreement<br>       ↓<br>&quot;How do we establish shared secret material?&quot;</pre><pre>Symmetric Encryption<br>       ↓<br>&quot;How do we efficiently protect the data?&quot;</pre><pre>Double Ratchet<br>       ↓<br>&quot;How do we continuously evolve our message keys?&quot;</pre><pre>E2EE<br>       ↓<br>&quot;How do we protect message content from intermediaries?&quot;</pre><p>Once you understand these responsibilities, cryptography becomes much easier to reason about.</p><p><strong>Part 3</strong> will move from theory to the iOS developer’s world: <strong>CryptoKit, AES-GCM, ChaChaPoly, Keychain, Secure Enclave, and practical Swift examples.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=72cc5cc5159e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Encryption for Mobile Developers: Symmetric vs Asymmetric Encryption and Hashing (Part 1)]]></title>
            <link>https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-1-symmetric-encryption-asymmetric-encryption-and-hashing-b3a50d729d88?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/b3a50d729d88</guid>
            <category><![CDATA[cryptography-basics]]></category>
            <category><![CDATA[mobile-app-security]]></category>
            <category><![CDATA[symmetric-encryption]]></category>
            <category><![CDATA[hashing-vs-encryption]]></category>
            <category><![CDATA[asymmetric-encryption]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Thu, 06 Aug 2026 12:49:47 GMT</pubDate>
            <atom:updated>2026-08-12T14:43:24.909Z</atom:updated>
            <content:encoded><![CDATA[<p><em>If you’ve ever been asked how WhatsApp keeps messages secure or why passwords are hashed instead of encrypted, understanding the fundamentals of cryptography is essential. Whether you’re an iOS developer, Android engineer, or preparing for a system design interview, these concepts form the foundation of modern application security.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YoZM_OuRmglw0cTO8BjGtw.png" /></figure><h3>Why Every Mobile Developer Should Understand Encryption</h3><p>Almost every application we use today handles sensitive information.</p><ul><li>Banking applications transfer financial data.</li><li>Healthcare applications store medical records.</li><li>Messaging applications exchange private conversations.</li><li>E-commerce applications process payment information.</li><li>Social media applications protect personal data.</li></ul><p>Imagine sending your banking password over public Wi-Fi without encryption. Anyone intercepting the network traffic could read it instantly.</p><p>Encryption prevents this by converting readable information into an unreadable format that only authorized parties can access.</p><p>As a mobile developer, you don’t need to invent encryption algorithms, but you <strong>must understand when and how to use them correctly</strong>.</p><h3>What Is Encryption?</h3><p>Encryption is the process of converting readable information (plaintext) into unreadable information (ciphertext) using a cryptographic algorithm and one or more keys.</p><pre>Plain Text<br>     │<br>     ▼<br>Encryption Algorithm + Key<br>     │<br>     ▼<br>Cipher Text<br>     │<br>     ▼<br>Decryption + Correct Key<br>     │<br>     ▼<br>Original Plain Text</pre><p>Without the correct key, the encrypted data appears as random characters.</p><p>For example:</p><pre>Hello Ana </pre><pre>↓</pre><pre>Encrypted</pre><pre>A93@!xQ#7LmP...</pre><p>Only someone with the correct decryption key can recover the original message.</p><h3>Encoding Is Not Encryption</h3><p>This distinction trips up a surprising number of candidates in interviews, so it’s worth settling early.</p><p>Base64, URL encoding, and hex are <strong>encoding</strong> schemes. They transform data into a different representation so it can travel safely through systems that expect text. They use <strong>no key</strong>, and anyone can reverse them instantly.</p><pre>Hello Ana<br>     │<br>     ▼<br>Base64<br>     │<br>     ▼<br>SGVsbG8gU2FiaWg=<br>     │<br>     ▼<br>Anyone can decode this. No key required.</pre><p>The output looks scrambled, which is exactly why it gets mistaken for encryption. But scrambled is not the same as secret.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iO2dj4V43ATYo1xooNdOQQ.png" /></figure><p>If you ever find yourself Base64-encoding an API token and calling it “encrypted,” stop. You’ve obscured it, not protected it.</p><h3>Why Do We Need Encryption?</h3><p>Encryption and its related primitives provide several distinct security properties. Keeping them separate in your head matters, because a system can satisfy one and completely fail another.</p><h3>Confidentiality</h3><p>Only authorized users can read the data. Even if an attacker captures the network traffic or steals the database file, the contents remain unreadable.</p><p>Example:</p><ul><li>WhatsApp messages</li><li>Banking transactions</li><li>Medical records</li><li>HTTPS communication</li><li>VPN connections</li></ul><h3>Integrity</h3><p>The data has not been modified in transit or at rest.</p><p>This one is easy to overlook. <strong>Encryption alone does not guarantee integrity.</strong> With certain older modes, an attacker who cannot read your ciphertext can still flip bits in it and cause the receiver to decrypt something different from what you sent. They don’t need to understand the message to tamper with it.</p><p>Example:</p><ul><li>Verifying a downloaded APK has not been altered</li><li>Ensuring a transaction amount arrives unchanged</li></ul><h3>Authenticity</h3><p>The data genuinely came from who it claims to have come from.</p><p>Confidentiality without authenticity leaves you open to an attacker who simply substitutes their own encrypted message for yours. Modern encryption modes bundle authenticity together with confidentiality for exactly this reason, which we’ll cover shortly.</p><p>Example:</p><ul><li>TLS server certificates</li><li>Signed software updates</li></ul><h3>Compliance</h3><p>Many industries require encryption by law or regulation.</p><p>Examples include:</p><ul><li>Healthcare</li><li>Finance</li><li>Government systems</li></ul><h3>Types of Encryption</h3><p>There are two major types of encryption:</p><ol><li>Symmetric Encryption</li><li>Asymmetric Encryption</li></ol><p>Let’s understand each one.</p><h3>Symmetric Encryption</h3><p>Symmetric encryption uses <strong>one shared secret key</strong> for both encryption and decryption.</p><pre>Secret Key</pre><pre>Sender ─────────────► Receiver</pre><pre>Encrypt               Decrypt</pre><pre>Same Key              Same Key</pre><p>Both parties must already know the same secret key.</p><h3>Real-Life Analogy</h3><p>Imagine you own a locker.</p><p>Both you and your friend have <strong>the exact same key</strong>.</p><ul><li>You lock the locker.</li><li>Your friend unlocks it.</li></ul><p>The same key performs both operations.</p><h3>How It Works</h3><pre><br>Hello</pre><pre>↓</pre><pre>AES Encryption</pre><pre>↓</pre><pre>Encrypted Message</pre><pre>↓</pre><pre>Internet</pre><pre>↓</pre><pre>AES Decryption</pre><pre>↓</pre><pre>Hello</pre><h3>Advantages</h3><p>✅ Extremely fast</p><p>✅ Suitable for large files</p><p>✅ Low CPU usage</p><p>✅ Perfect for continuous communication</p><h3>Disadvantages</h3><p>The biggest challenge is <strong>securely sharing the secret key</strong>.</p><p>How do you safely send the key to another person without exposing it?</p><p>This is known as the <strong>key distribution problem</strong>.</p><h3>Real-World Examples</h3><p>Symmetric encryption is commonly used for:</p><ul><li>WhatsApp message encryption (after a secure session is established)</li><li>Database encryption</li><li>Disk encryption</li><li>iPhone backup encryption</li><li>HTTPS session encryption</li><li>VPN communication</li></ul><h3>Common Algorithms</h3><ul><li><strong>AES</strong> — available with 128-bit, 192-bit, and 256-bit keys</li><li><strong>ChaCha20</strong></li></ul><p>A common misconception is that AES-128, AES-192, and AES-256 are three different algorithms. They are the same algorithm with three key sizes. AES-256 is widely used because it provides strong security with excellent performance, though AES-128 remains perfectly secure for most applications and is slightly faster.</p><h3>Choosing a Mode: Why “AES Encryption” Is Not a Complete Answer</h3><p>Saying you used “AES” describes only half of what you did. AES is a <strong>block cipher</strong> — it encrypts one fixed-size block at a time. A <strong>mode of operation</strong> determines how those blocks are chained together to encrypt a message of arbitrary length, and different modes give you very different security properties.</p><p>This is where the integrity property from earlier becomes concrete.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IjR7M2AHTgmtYAe5ZaZ9ww.png" /></figure><p>AES-GCM and ChaCha20-Poly1305 are A<strong>EAD</strong> modes — <strong>Authenticated Encryption with Associated Data</strong>. They produce an authentication tag alongside the ciphertext, and decryption fails outright if the ciphertext has been tampered with.</p><p>If you use AES-CBC without adding a message authentication code, your ciphertext is malleable. An attacker who cannot read it can still modify it in predictable ways, and your app will happily decrypt the result.</p><p><strong>Practical guidance for mobile:</strong></p><ul><li>Prefer AES-GCM or ChaCha20-Poly1305. On iOS, CryptoKit gives you AES.GCM and ChaChaPoly. On Android, use AES/GCM/NoPadding via javax.crypto, or the Jetpack Security library.</li><li>Never reuse a nonce (initialization vector) with the same key. With GCM this is catastrophic, not merely sloppy — it can leak the authentication key.</li><li>Never hard-code keys in your app. Use the iOS Keychain / Secure Enclave or the Android Keystore.</li><li>Avoid ECB entirely. It encrypts identical plaintext blocks to identical ciphertext blocks, which leaks the structure of your data.</li></ul><h3>Asymmetric Encryption</h3><p>Asymmetric encryption solves the key distribution problem.</p><p>Instead of one key, it uses <strong>two mathematically related keys</strong>:</p><ul><li>Public Key</li><li>Private Key</li></ul><pre>Public Key  → Anyone can know it<br><br>Private Key → Only the owner possesses it</pre><h3>Real-Life Analogy</h3><p>Think of a mailbox.</p><p>Anyone can drop a letter into your mailbox.</p><p>However, only you have the key to open it.</p><pre>Public Key</pre><pre>Drop Letter</pre><pre>↓</pre><pre>Mailbox</pre><pre>↓</pre><pre>Private Key</pre><pre>↓</pre><pre>Read Letter</pre><h3>How It Works</h3><p>Alice wants to send a secure message to Bob.</p><ol><li>Bob generates a public/private key pair.</li><li>Bob shares only his public key.</li><li>Alice encrypts the message using Bob’s public key.</li><li>Bob decrypts it using his private key.</li></ol><pre>Message</pre><pre>↓</pre><pre>Bob&#39;s Public Key</pre><pre>↓</pre><pre>Encrypted Message</pre><pre>↓</pre><pre>Internet</pre><pre>↓</pre><pre>Bob&#39;s Private Key</pre><pre>↓</pre><pre>Original Message</pre><p>Even if someone intercepts the encrypted message, they cannot decrypt it without Bob’s private key.</p><h3>Three Ways Public-Key Cryptography Is Actually Used</h3><p>The mailbox model above describes <strong>key transport</strong> — encrypting directly with someone’s public key. It’s the easiest version to visualise, and it’s the one most tutorials stop at. But it is only one of three uses, and in modern protocols it is the least common of the three.</p><p><strong>1. Encryption (key transport)</strong> Encrypt with the recipient’s public key; only their private key decrypts it. This is the mailbox.</p><p><strong>2. Key agreement</strong> Two parties each combine their own private key with the other’s public key and independently arrive at the <em>same</em> shared secret, without that secret ever crossing the network. This is Diffie–Hellman, and in its elliptic-curve form (ECDH) it is what secures nearly all modern traffic.</p><pre>Alice&#39;s Private Key + Bob&#39;s Public Key  ──┐<br>                                          ├──► Same Shared Secret<br>Bob&#39;s Private Key   + Alice&#39;s Public Key ──┘</pre><pre>The shared secret is never transmitted.</pre><p><strong>3. Digital signatures</strong> Sign with your private key; anyone can verify with your public key. This provides authenticity and integrity rather than confidentiality.</p><p><strong>Why this matters:</strong> TLS 1.3 removed RSA key transport entirely. Every TLS 1.3 connection uses ECDHE for key agreement plus a signature for server authentication. WhatsApp’s X3DH is likewise built on Diffie–Hellman key agreement, not public-key encryption.</p><p>So the accurate summary is not “HTTPS encrypts with the server’s public key.” It’s closer to: the two sides <em>agree</em> on a shared secret using ECDHE, the server proves its identity with a signature, and the resulting shared secret keys a symmetric cipher for the rest of the session. Part 2 walks through this handshake step by step.</p><h3>Advantages</h3><p>✅ Secure key exchange</p><p>✅ No need to share secret keys beforehand</p><p>✅ Enables digital signatures</p><p>✅ Supports authentication</p><h3>Disadvantages</h3><p>Compared to symmetric encryption, it is:</p><ul><li>Slower</li><li>More CPU intensive</li><li>Not ideal for encrypting large amounts of data</li></ul><p>Because of this, asymmetric encryption is <strong>typically used to establish trust and exchange keys</strong>, while symmetric encryption is used for the actual data transfer. This combination is called a <strong>hybrid cryptosystem</strong>, and essentially every real-world secure protocol is one.</p><h3>Real-World Examples</h3><p>Asymmetric encryption is used in:</p><ul><li>HTTPS (TLS handshake)</li><li>WhatsApp key exchange</li><li>SSH authentication</li><li>Email encryption</li><li>Digital certificates</li><li>Secure software distribution</li></ul><h3>Common Algorithms</h3><p><strong>Key exchange / agreement:</strong></p><ul><li>ECDH, especially the X25519 curve</li><li>Diffie–Hellman (classic, finite-field)</li></ul><p><strong>Digital signatures:</strong></p><ul><li>Ed25519</li><li>ECDSA (P-256)</li><li>RSA-PSS</li></ul><p><strong>Encryption (key transport):</strong></p><ul><li>RSA-OAEP, with 2048-bit keys minimum and 3072 or 4096 preferred for long-lived data</li></ul><p>Note that plain “textbook” RSA without proper padding is insecure. If you see RSA used without OAEP or PSS, treat it as a finding.</p><p><strong>Elliptic curve versus RSA:</strong> ECC achieves comparable security with dramatically smaller keys. A 256-bit elliptic curve key is roughly equivalent in strength to a 3072-bit RSA key. Smaller keys mean faster operations, less battery drain, and smaller handshakes — all of which matter meaningfully on mobile. Prefer X25519 and Ed25519 for new work.</p><h3>Hashing</h3><p>Hashing is <strong>not encryption</strong>.</p><p>This is one of the most common interview questions.</p><p>A hash function converts data into a fixed-length value called a <strong>hash</strong> or <strong>digest</strong>.</p><pre>Password</pre><pre>↓</pre><pre>Hash Function</pre><pre>↓</pre><pre>4f8e2d7b91...</pre><p>Unlike encryption, hashing is <strong>one-way</strong>.</p><p>You cannot reverse a secure hash to recover the original input.</p><h3>Butterfly Effect</h3><p>A tiny change in the input produces a completely different hash.</p><pre>Hello</pre><pre>↓</pre><pre>185f8db...</pre><pre>Hello!</pre><pre>↓</pre><pre>334d016...</pre><p>Even adding a single character creates a dramatically different result.</p><h3>Storing Passwords: Hashing Alone Is Not Enough</h3><p>Here is the naive approach, and the one most tutorials show:</p><pre>MyPassword123</pre><pre>↓</pre><pre>SHA-256</pre><pre>↓</pre><pre>3f82bc91d6ab9...   ← stored in database</pre><p>At login, the server hashes the entered password and compares it to the stored value. The original password never needs to be stored, which is the right instinct.</p><p>But this scheme has two serious problems.</p><p><strong>Problem 1: identical passwords produce identical hashes.</strong></p><p>If two users both choose MyPassword123, their stored hashes are byte-for-byte identical. An attacker who breaches your database immediately learns which accounts share a password, and cracking one cracks them all. Worse, precomputed lookup tables (rainbow tables) for common passwords already exist, so no cracking is even required.</p><p><strong>Problem 2: general-purpose hashes are built to be fast.</strong></p><p>SHA-256 is designed for speed — that’s a feature when you’re verifying a file download. It’s a catastrophe for passwords. Commodity GPU hardware can compute billions of SHA-256 hashes per second, so an attacker can exhaust an enormous keyspace in hours.</p><h3>Fix 1: Salt</h3><p>A <strong>salt</strong> is a unique random value, generated per user, stored in plaintext alongside the hash.</p><pre>User A:  &quot;MyPassword123&quot; + salt_A  →  hash_A<br>User B:  &quot;MyPassword123&quot; + salt_B  →  hash_B</pre><pre>Same password. Completely different stored hashes.</pre><p>The salt does not need to be secret. Its only job is to make each hash unique, which defeats rainbow tables and forces an attacker to attack every account separately rather than all of them at once. Use at least 16 random bytes from a cryptographically secure random source.</p><h3>Fix 2: A Deliberately Slow Algorithm</h3><p>Password hashing functions are engineered to be <em>expensive</em>. They take a cost parameter you tune upward as hardware improves, and the memory-hard ones resist GPU and ASIC acceleration specifically.</p><pre>SHA-256:  billions of guesses per second   ← wrong tool<br>bcrypt:   thousands of guesses per second  ← right tool<br>Argon2id: thousands, and memory-bound      ← best tool</pre><p>A delay of around 100 to 500 milliseconds is imperceptible to a legitimate user logging in once, and devastating to an attacker making billions of attempts.</p><h3>The Rule</h3><blockquote><strong><em>Never hash passwords with SHA-256, SHA-512, or any general-purpose hash function — even with a salt.</em></strong><em> Use Argon2id, bcrypt, or PBKDF2.</em></blockquote><p>Modern password hashing libraries generate the salt for you and embed it, along with the cost parameters, in the output string. You typically store one field, not two.</p><p><strong>One note for mobile specifically:</strong> password hashing belongs on the server, not in your app. The client sends the password over TLS; the server does the hashing. Hashing client-side and treating the result as the credential just makes the hash itself the password. Where you <em>do</em> legitimately use these functions on-device is key derivation — turning a user passphrase into an encryption key, which is what PBKDF2 and Argon2 are also designed for.</p><h3>Common Uses of Hashing</h3><p>Hashing is commonly used for:</p><ul><li>Password storage</li><li>File integrity verification</li><li>Blockchain</li><li>Digital signatures</li><li>Checksums</li><li>Data validation</li></ul><h3>Common Hash Algorithms</h3><p>General-purpose hashing:</p><ul><li>SHA-256</li><li>SHA-384</li><li>SHA-512</li><li>SHA-3</li><li>BLAKE2 / BLAKE3</li></ul><p>Password hashing and key derivation:</p><ul><li>Argon2id (preferred for new systems)</li><li>bcrypt</li><li>scrypt</li><li>PBKDF2 (widely available; use a high iteration count)</li></ul><p>Avoid using MD5 and SHA-1 for security-sensitive applications because they have known weaknesses. Practical collision attacks exist against both. MD5 is still acceptable as a non-security checksum for detecting accidental corruption, but never for anything an adversary could target.</p><h3>A Footnote on Keyed Hashing</h3><p>The table below says hashing uses no keys, which is true of a bare hash function. There is one important construction worth knowing: <strong>HMAC</strong> combines a hash function with a secret key to produce a message authentication code.</p><pre>HMAC-SHA256(key, message) → tag</pre><p>Only someone holding the key can produce or verify a valid tag, which makes HMAC a tool for integrity <em>and</em> authenticity rather than plain fingerprinting. It’s what you’d pair with AES-CBC if you couldn’t use an AEAD mode, and it’s the standard way to sign API requests and webhooks.</p><p>One practical detail: always compare tags and hashes with a <strong>constant-time</strong> comparison function. An ordinary == returns early on the first differing byte, and that timing difference is measurable enough to leak the expected value.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o2P5EikLY4tCmK-HgG1GKg.png" /><figcaption>Encryption VS Hashing Comparison</figcaption></figure><h3>When Should You Use Each?</h3><p>Use <strong>Encryption</strong> when data must be read again later.</p><p>Examples:</p><ul><li>Chat messages</li><li>Bank transactions</li><li>Files</li><li>API communication</li></ul><p>Use <strong>Hashing</strong> when you only need to verify data without recovering it.</p><p>Examples:</p><ul><li>Password storage</li><li>File verification</li><li>Data integrity</li></ul><p>And to complete the set: use <strong>encoding</strong> when you need to move data safely through a text-based channel, and never for security.</p><h3>Key Takeaways</h3><p>Understanding the difference between symmetric encryption, asymmetric encryption, and hashing is essential for every mobile developer.</p><p>A useful rule of thumb is:</p><ul><li><strong>Symmetric encryption</strong> is fast and ideal for encrypting large amounts of data. Reach for AES-GCM or ChaCha20-Poly1305 so you get integrity along with confidentiality.</li><li><strong>Asymmetric encryption</strong> is used to securely exchange keys and verify identities. In modern protocols this usually means ECDH key <em>agreement</em> and signatures, not encrypting with a public key directly.</li><li><strong>Hashing</strong> creates a one-way fingerprint of data. For passwords specifically, use a salted, deliberately slow function such as Argon2id or bcrypt — never SHA-256.</li><li><strong>Encoding</strong> such as Base64 is not encryption and provides no security whatsoever.</li></ul><p>Two ideas are worth internalising above the rest. First, confidentiality and integrity are separate properties, and encryption on its own only buys you the first. Second, every real secure system is a hybrid: asymmetric cryptography to establish trust and derive a shared key, symmetric cryptography to move the actual data.</p><p>Modern secure systems — including WhatsApp, banking applications, HTTPS, and cloud services — combine these techniques rather than relying on just one.</p><p>In <a href="https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-2-72cc5cc5159e"><strong>Part 2</strong></a>, we’ll explore how these concepts come together in real-world systems by covering <strong>Digital Signatures, the HTTPS/TLS Handshake, and how WhatsApp’s End-to-End Encryption works using the Signal Protocol</strong>.</p><p><a href="https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-2-72cc5cc5159e">https://medium.com/@sabihhida88/encryption-for-mobile-developers-part-2-72cc5cc5159e</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b3a50d729d88" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Actor Reentrancy]]></title>
            <link>https://medium.com/@sabihhida88/concurrency-interview-questions-a32f7dda7305?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/a32f7dda7305</guid>
            <category><![CDATA[ios-apps]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[ios-app-development]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Wed, 05 Aug 2026 06:06:38 GMT</pubDate>
            <atom:updated>2026-08-05T06:07:35.145Z</atom:updated>
            <content:encoded><![CDATA[<h3>What is actor reentrancy? Can it cause bugs?</h3><p>Yes. <strong>Actor reentrancy</strong> is one of the most important concepts to understand when working with Swift Concurrency because it can lead to subtle bugs if you assume an actor executes a function from start to finish without interruption.</p><h3>What is Actor Reentrancy?</h3><p>Actors protect their mutable state by allowing <strong>only one task to access their state at a time</strong>.</p><p>However, <strong>when an actor method reaches an </strong><strong>await, the actor is temporarily released</strong> so it can process other queued tasks.</p><p>When the awaited operation completes, your function resumes — but <strong>the actor’s state may have changed</strong>.</p><p>This behavior is called <strong>actor reentrancy</strong>.</p><h3>Example</h3><pre>actor BankAccount {<br>    var balance = 1000</pre><pre>    func withdraw(amount: Int) async {<br>        guard balance &gt;= amount else {<br>            print(&quot;Not enough balance&quot;)<br>            return<br>        }</pre><pre>        // Suspension point<br>        await authorizeTransaction()</pre><pre>        balance -= amount<br>        print(&quot;Remaining:&quot;, balance)<br>    }</pre><pre>    func authorizeTransaction() async {<br>        try? await Task.sleep(for: .seconds(2))<br>    }<br>}</pre><p>Now imagine this:</p><pre>let account = BankAccount()</pre><pre>Task {<br>    await account.withdraw(amount: 800)<br>}</pre><pre>Task {<br>    await account.withdraw(amount: 500)<br>}</pre><h3>What happens?</h3><h4>Task 1</h4><pre>Balance = 1000<br>Checks balance ✔️<br>await authorizeTransaction()</pre><p>The actor is now free.</p><h4>Task 2 starts</h4><pre>Balance is STILL 1000<br>Checks balance ✔️<br>await authorizeTransaction()</pre><p>The actor is free again.</p><h4>Task 1 resumes</h4><pre>balance = 1000 - 800 = 200</pre><h4>Task 2 resumes</h4><pre>balance = 200 - 500 = -300 ❌</pre><p>Both withdrawals passed the balance check because the check happened <strong>before</strong> the await, but the balance changed <strong>during</strong> the suspension.</p><h3>Why does this happen?</h3><p>Because</p><pre>await something()</pre><p>means</p><blockquote><em>“Pause this function. Let the actor process other work while waiting.”</em></blockquote><p>So the actor state is <strong>not guaranteed to be the same after the </strong><strong>await</strong>.</p><h3>How to avoid these bugs</h3><h3>✅ Option 1: Re-check state after await</h3><pre>func withdraw(amount: Int) async {<br>    await authorizeTransaction()</pre><pre>    guard balance &gt;= amount else {<br>        return<br>    }</pre><pre>    balance -= amount<br>}</pre><p>Now you’re making the decision using the latest state.</p><h3>✅ Option 2: Don’t suspend while relying on mutable actor state</h3><p>Move the asynchronous work outside the critical section.</p><pre>await authorizeTransaction()<br>await account.withdrawConfirmed(amount: 500)</pre><p>where</p><pre>actor BankAccount {<br>    func withdrawConfirmed(amount: Int) {<br>        guard balance &gt;= amount else { return }<br>        balance -= amount<br>    }<br>}</pre><h3>✅ Option 3: Capture immutable values before await</h3><p>If the value won’t change or doesn’t depend on mutable state, copy it into a local constant before suspension.</p><h3>Key rule to remember</h3><p>Every await inside an actor is a potential point where:</p><ul><li>another task can enter the actor,</li><li>modify its state,</li><li>and leave before your function resumes.</li></ul><p>Never assume actor state is unchanged after an await.</p><h3>Simple analogy</h3><p>Think of an actor as a <strong>single-person office</strong>.</p><ul><li>While the worker is busy, nobody else can enter.</li><li>If the worker leaves to make a phone call (await), the office door unlocks.</li><li>Someone else can come in, rearrange the files, and leave.</li><li>When the worker returns, the desk may no longer look the same.</li></ul><p>That’s exactly what actor reentrancy is.</p><h3>Interview takeaway</h3><blockquote><strong><em>Actor reentrancy means an actor can process other tasks while one of its methods is suspended at an </em></strong><strong><em>await. This keeps actors responsive, but it also means the actor&#39;s state may change before the suspended method resumes. To avoid bugs, don&#39;t assume actor state remains unchanged across suspension points—revalidate state after </em></strong><strong><em>await or structure code so critical state updates occur without suspension.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a32f7dda7305" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Would Design a Scalable Chat Application in an iOS System Design Interview]]></title>
            <link>https://medium.com/@sabihhida88/how-i-would-design-a-scalable-chat-application-in-an-ios-system-design-interview-55dd1ffb2ab3?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/55dd1ffb2ab3</guid>
            <category><![CDATA[design-systems]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[tech-interview]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 16:33:16 GMT</pubDate>
            <atom:updated>2026-07-28T16:33:16.296Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Building a chat application like WhatsApp or Slack is one of the most common system design questions for senior iOS engineers. Here’s how I approach it in interviews.</em></p><h3>Introduction</h3><p>When interviewers ask you to design a chat application, they aren’t looking for a perfect architecture diagram or expecting you to memorise every backend component.</p><p>They want to evaluate how you think.</p><p>Can you identify requirements? Can you make sound architectural decisions? Can you design something that remains reliable, scalable, and maintainable as millions of users join the platform?</p><p>In this article, I’ll walk through the approach I use when answering this question in senior iOS interviews.</p><h3>Step 1: Clarify the Requirements</h3><p>Before drawing any diagrams, spend a minute clarifying the problem.</p><h3>- Functional Requirements</h3><ul><li>One-to-One Chat</li><li>Group Chat</li><li>Image &amp; Video Sharing</li><li>Voice Messages</li><li>Read Receipts</li><li>Typing Indicators</li><li>Push Notifications</li><li>Message Search</li><li>Offline Support</li></ul><h3>- Non-Functional Requirements</h3><ul><li>Low latency</li><li>High availability</li><li>Scalability</li><li>Security</li><li>Battery efficiency</li><li>Reliable message delivery</li></ul><p>Starting with requirements shows interviewers that you solve problems methodically rather than jumping straight into implementation.</p><h3>Step 2: Design the Client Architecture</h3><p>For the iOS application, I typically choose <strong>Clean Architecture with MVVM</strong>.</p><pre>ChatView<br>↓</pre><pre>ChatViewModel</pre><pre>↓</pre><pre>Use Cases</pre><pre>↓</pre><pre>Repository</pre><pre>↓</pre><pre>Core Data<br>REST API<br>WebSocket</pre><p>Each layer has a single responsibility.</p><ul><li><strong>View</strong> renders the UI.</li><li><strong>ViewModel</strong> manages presentation state.</li><li><strong>Use Cases</strong> contain business logic.</li><li><strong>Repository</strong> decides where data comes from.</li><li><strong>Data Layer</strong> communicates with local storage and backend services.</li></ul><p>This architecture is testable, maintainable, and easy to extend.</p><h3>Step 3: Think Offline First</h3><p>One mistake many candidates make is assuming the network is always available.</p><p>Real chat applications continue to work even when connectivity is lost.</p><p>Instead of waiting for the server, I immediately save the message locally.</p><pre>User taps Send<br>↓</pre><pre>Save to Core Data<br>↓</pre><pre>Update UI instantly<br>↓</pre><pre>Send through WebSocket<br>↓</pre><pre>Receive ACK<br>↓</pre><pre>Update status to Sent</pre><p>The user experiences an instant response, while the network operation happens in the background.</p><h3>Step 4: Real-Time Communication</h3><p>HTTP polling doesn’t scale well for chat.</p><p>Instead, I use <strong>WebSockets</strong> to maintain a persistent connection between the client and server.</p><p>Advantages include:</p><ul><li>Lower latency</li><li>Reduced network overhead</li><li>Better battery efficiency</li><li>Instant message delivery</li></ul><p>The WebSocket manager is responsible for:</p><ul><li>Connecting</li><li>Disconnecting</li><li>Heartbeats</li><li>Automatic reconnection</li><li>Receiving events</li><li>Authentication</li></ul><h3>Step 5: Handle Connection Failures</h3><p>Networks fail.</p><p>Users switch between Wi-Fi and cellular networks.</p><p>Applications move to the background.</p><p>Servers restart.</p><p>A production-ready application must detect these situations automatically.</p><p>I implement a heartbeat mechanism.</p><pre>Client → Ping → Server<br>Server → Pong → Client<br>No Pong in time → Reconnect</pre><p>If no Pong is received within the timeout period, the client assumes the connection has been lost and reconnects using exponential backoff.</p><h3>Step 6: Synchronise Efficiently with Delta Sync</h3><p>Imagine downloading every message every time the application opens.</p><p>That approach doesn’t scale.</p><p>Instead, I use <strong>Delta Sync</strong>.</p><p>The client stores its last successful sync timestamp.</p><pre>Last Sync<br>↓</pre><pre>GET /messages?since=timestamp</pre><pre>↓</pre><pre>Server returns only new changes</pre><p>Those changes may include:</p><ul><li>New messages</li><li>Edited messages</li><li>Deleted messages</li><li>Read receipts</li><li>Reactions</li><li>Group updates</li></ul><p>This dramatically reduces bandwidth and improves application launch performance.</p><h3>Step 7: Optimise Performance</h3><p>Performance matters just as much as functionality.</p><p>Some optimisations include:</p><ul><li>Cursor-based pagination</li><li>Lazy loading</li><li>Image caching</li><li>Thumbnail generation</li><li>Background uploads</li><li>Incremental UI updates</li></ul><p>Instead of loading thousands of messages, I fetch the latest page first and load older conversations as the user scrolls.</p><h3>Step 8: Secure the Application</h3><p>Security is essential for any messaging platform.</p><p>My baseline security considerations include:</p><ul><li>TLS encryption</li><li>Secure token storage using Keychain</li><li>Certificate pinning (where appropriate)</li><li>Authentication refresh</li><li>End-to-end encryption by default, using a protocol such as Signal’s Double Ratchet</li></ul><h3>Step 9: Explain Your Trade-offs</h3><p>One of the biggest differences between mid-level and senior engineers is the ability to explain <em>why</em> they chose a solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DqwxySDhovODSzhvIVuxMg.png" /></figure><p>Interviewers care less about the technology itself and more about your reasoning.</p><h3>Common Interview Mistakes</h3><p>Some mistakes I frequently see include:</p><ul><li>Jumping directly into coding.</li><li>Ignoring offline behaviour.</li><li>Forgetting retry mechanisms.</li><li>Reloading the entire chat history.</li><li>Not discussing scalability.</li><li>Ignoring failure scenarios.</li></ul><p>A senior engineer should always think beyond the happy path.</p><h3>Final Thoughts</h3><p>A scalable chat application isn’t just about sending messages.</p><p>It’s about building a system that remains responsive under unreliable networks, synchronises data efficiently, recovers gracefully from failures, and continues to perform well as the number of users grows.</p><p>In interviews, remember that the goal isn’t to design the next WhatsApp in 30 minutes.</p><p>The goal is to demonstrate structured thinking, sound architectural decisions, and the ability to balance user experience, scalability, and maintainability.</p><p>Those are the qualities interviewers are really evaluating.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55dd1ffb2ab3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most Mood Apps Help You Track Feelings. I wanted to build one that helps you understand them.]]></title>
            <link>https://medium.com/@sabihhida88/most-mood-apps-help-you-track-feelings-i-wanted-to-build-one-that-helps-you-understand-them-efeeee7bc021?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/efeeee7bc021</guid>
            <category><![CDATA[startup]]></category>
            <category><![CDATA[emotional-wellness]]></category>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[self-care]]></category>
            <category><![CDATA[mood-tracker]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Tue, 07 Apr 2026 11:08:38 GMT</pubDate>
            <atom:updated>2026-04-07T11:08:38.732Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RZW69gxkzA-H1il7Ra0ZFg.png" /></figure><p>There are thousands of apps in the <strong>mood tracker</strong>, <strong>mental wellness</strong>, and <strong>self-care</strong> space. Most of them help you log how you feel. Very few help you understand <strong>why</strong> you feel that way.</p><p>That gap is exactly why I built <strong>EmoteTrack</strong>.</p><p>EmoteTrack is a <strong>mood-tracking app designed to help people move beyond simple check-ins</strong> toward something more useful: <strong>emotional clarity</strong>, <strong>self-awareness</strong>, and a better understanding of the patterns behind everyday feelings.</p><h3>The problem with most mood tracker apps</h3><p>A lot of mood tracker apps follow the same formula:</p><ul><li>open the app</li><li>tap an emotion</li><li>Maybe write a note</li><li>Close the app</li></ul><p>That flow is simple, but it often stops too early.</p><p>Knowing you felt stressed today is helpful.<br>Knowing what may have <strong>triggered</strong> that stress, what time it tends to show up, and what helps you recover is much more valuable.</p><p>That is the difference between a basic <strong>mood diary</strong> and a product that can actually support <strong>emotional wellness</strong>.</p><p>I didn’t want to build just another <strong>emotion tracker</strong>.</p><p>I wanted to build a product that helps people notice:</p><ul><li>What adds pressure</li><li>What supports recovery</li><li>What emotional states repeat</li><li>How mood patterns change over time</li></ul><h3>Why emotional patterns matter</h3><p>Many of our emotional experiences are not random. Stress often repeats around the same pressures. Anxiety can cluster around certain situations.<br>Calm may show up more often in very specific conditions. Even overwhelm tends to have patterns. But most people are too busy living their lives to step back and see those patterns clearly.</p><p>That is where a better <strong>mood tracker app</strong> can become useful.</p><p>Not just as a place to log moods, but as a tool for:</p><ul><li><strong>daily reflection</strong></li><li><strong>stress tracking</strong></li><li><strong>anxiety awareness</strong></li><li><strong>self-care</strong></li><li><strong>emotional pattern recognition</strong></li><li><strong>building self-awareness</strong></li></ul><p>That is the core idea behind EmoteTrack.</p><h3>What EmoteTrack is trying to do differently</h3><p>EmoteTrack is built around one simple promise:</p><p><strong>See what shapes your mood.</strong></p><p>That sounds small, but it changes the whole product.</p><p>Instead of only asking:<br><strong>How do you feel?</strong></p><p>The app also tries to help users explore:</p><ul><li>What may be shaping this feeling?</li><li>What keeps repeating?</li><li>What adds emotional pressure?</li><li>What seems to support recovery?</li><li>Is this week feeling lighter, heavier, or more mixed than usual?</li></ul><p>This turns a simple <strong>mood log</strong> into something more meaningful.</p><p>With EmoteTrack, users can:</p><ul><li>Log their mood in seconds</li><li>Add optional context like social factors and weather</li><li>Review mood history in a calendar view</li><li>Explore emotional trends across time</li><li>See pressure, support, and recovery signals</li><li>Build a personal <strong>Mood Profile</strong></li><li>Reflect on emotional patterns over days, weeks, and months</li></ul><p>That is where mood tracking starts becoming more useful than a list of old entries.</p><h3>Building a mood tracker that feels simple but useful</h3><p>One of the biggest challenges while building EmoteTrack has been this:</p><p>How do you make a <strong>mood tracker</strong> feel light enough for daily use, while still making it smart enough to provide useful insight?</p><p>That balance matters.</p><p>If the app is too simple, it becomes forgettable.<br>If the app is too heavy, people stop using it.</p><p>I wanted EmoteTrack to sit in the middle:</p><ul><li>fast enough for a quick daily check-in</li><li>clear enough to avoid confusion</li><li>thoughtful enough to support emotional reflection</li><li>useful enough to reveal real patterns over time</li></ul><p>That is why the product is designed to reduce friction.</p><p>The goal is not to make users fill out a giant emotional form every day.</p><p>The goal is to help them:</p><ul><li>Check in quickly</li><li>build a habit</li><li>collect useful emotional signals</li><li>turn repeated check-ins into <strong>emotional insight</strong></li></ul><h3>From mood logging to emotional clarity</h3><p>What makes a <strong>mood tracker app</strong> valuable is not the act of logging alone.</p><p>It is the payoff.</p><p>A strong emotional product should help people feel:</p><ul><li>more aware</li><li>more grounded</li><li>more informed</li><li>more in control</li><li>less confused by repeating emotional cycles</li></ul><p>That is why EmoteTrack focuses on:</p><ul><li><strong>Mood Profile</strong></li><li><strong>pressure signals</strong></li><li><strong>recovery patterns</strong></li><li><strong>weekly reflection</strong></li><li><strong>emotional history</strong></li><li><strong>calendar-based mood review</strong></li></ul><p>The idea is not to overwhelm people with charts.</p><p>It is to help them notice something useful.</p><p>For example:</p><ul><li>This week felt heavier than usual</li><li>Stress tended to appear around time pressure</li><li>Recovery signals were limited</li><li>Support showed up less than expected</li><li>Late nights were emotionally harder</li><li>Rest or supportive connection helped steady things</li></ul><p>That kind of language is much more useful than a generic:<br><strong>You logged 4 sad moods this week.</strong></p><h3>What I learned while building EmoteTrack</h3><p>One of the biggest lessons has been this:</p><p><strong>A beautiful interface is not enough.</strong></p><p>It is easy to make a wellness app look calm.<br>It is much harder to make it genuinely trustworthy.</p><p>A product like this lives or dies on whether users believe the insights.</p><p>If the app gives one strange or misleading emotional conclusion, trust drops immediately.</p><p>So a lot of the work behind EmoteTrack has been about improving the product logic:</p><ul><li>When should an insight be shown?</li><li>When should the app stay cautious?</li><li>What counts as pressure?</li><li>What counts as support?</li><li>What counts as recovery?</li><li>When is the signal still too weak?</li><li>How do you avoid fake-smart language?</li></ul><p>That part matters more than people think. Because emotional products should not pretend to know more than they do. They should help users understand patterns honestly.</p><h3>Who EmoteTrack is for</h3><p>EmoteTrack is for people who want:</p><ul><li>a better <strong>mood tracker</strong></li><li>a simple <strong>feelings diary</strong></li><li>a calmer <strong>self-care app</strong></li><li>more consistent <strong>daily reflection</strong></li><li>stronger <strong>self-awareness</strong></li><li>a practical way to notice <strong>stress patterns</strong></li><li>a private tool for emotional check-ins</li><li>a simple way to reflect on anxiety, calm, overwhelm, and recovery</li></ul><p>It is especially useful for people who often feel:</p><ul><li>overwhelmed</li><li>emotionally scattered</li><li>unsure what affects their mood</li><li>curious about their emotional triggers</li><li>interested in improving emotional awareness without turning it into work</li></ul><p>Not everyone wants a therapy-style app.<br>Not everyone wants to journal every day.</p><p>A lot of people just want a clean way to check in and better understand themselves over time.</p><p>That is the space EmoteTrack is trying to fill.</p><h3>The bigger vision</h3><p>At its core, EmoteTrack is built around one belief:</p><p><strong>Your emotions are not just moments to record. They are patterns worth understanding.</strong></p><p>That does not mean every feeling needs to be analyzed.</p><p>It means that with the right structure, even small emotional check-ins can become something more meaningful:</p><ul><li>a better understanding of your triggers</li><li>a clearer picture of your emotional habits</li><li>a more honest view of what drains you</li><li>a calmer sense of what helps you recover</li></ul><p>That is the kind of <strong>mood tracking app</strong> I wanted to build.</p><p>Not just something that stores feelings.</p><p>Something that helps users understand them.</p><h3>Final thought</h3><p>There are a lot of apps that can help you log a mood.</p><p>I wanted to build one that helps you understand your emotional patterns, spot what adds pressure, and recognize what supports recovery.</p><p>That is what EmoteTrack is becoming.</p><p>If you have ever wanted a <strong>mood tracker</strong>, <strong>emotion journal</strong>, or <strong>daily reflection app</strong> that feels simple, calm, and more insightful than a basic diary, I’d love for you to check out EmoteTrack and share your honest feedback.</p><p>Because the real goal is not just to ask:</p><p><strong>How do I feel?</strong></p><p>It is to help answer:</p><p><strong>What keeps shaping my emotional state?</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=efeeee7bc021" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Most iOS Developers Are Using AI Wrong — and It’s Costing Them Time]]></title>
            <link>https://medium.com/@sabihhida88/most-ios-developers-are-using-ai-wrong-and-its-costing-them-time-9fedfac1dd2b?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fedfac1dd2b</guid>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Tue, 07 Apr 2026 08:19:22 GMT</pubDate>
            <atom:updated>2026-04-07T08:19:22.161Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kUyPZ1xyT6qbmvu1ZqwfhA.png" /></figure><p>AI should be making development faster.</p><p>But for many iOS developers, it does the opposite.</p><p>They open ChatGPT, Claude, or Codex, type something vague like <em>“build a login screen”</em> or <em>“fix this bug,”</em> and then get frustrated when the result is bloated, generic, or not usable in a real project.</p><p>The problem usually is not the tool.</p><p>It’s the prompt.</p><p>Most developers are still using AI for casual chat. That’s the mistake. If you want useful output, you need to give useful instructions. AI works much better when you treat it like a fast assistant that needs clarity, not like magic that reads your mind.</p><h3>Why weak prompts fail</h3><p>A weak prompt creates weak output.</p><p>If your request is vague, AI has to guess.<br>If your request is too broad, AI tries to do too much.<br>If your request has no boundaries, the answer becomes messy.</p><p>That is why prompts like these often fail:</p><pre>Build a chat app<br>Improve this code<br>Fix this issue</pre><p>They sound normal, but they are badly scoped.</p><h4>What works better</h4><p>A strong prompt usually has five parts:</p><ol><li>Give it a role</li><li>Define one task</li><li>Add requirements</li><li>Limit the scope</li><li>Control the output</li></ol><pre>Act as a senior iOS engineer<br><br>Task: Build a login screen<br><br>Requirements:<br>- Email + password<br>- Validation<br>- Async API call<br><br>Constraints:<br>- SwiftUI<br>- MVVM<br><br>Scope:<br>- View + ViewModel only<br><br>Output:<br>- Code only<br>- Max 120 lines<br>- No explanation</pre><p>This saves time and keeps the result practical.</p><h3>The biggest mistake developers make</h3><p>The dumbest way to use AI is to ask for everything in one shot.</p><p>Something like:</p><blockquote><em>Build a full chat app with UI, backend, and tests</em></blockquote><p>That usually leads to bloated garbage.</p><p>A better workflow is:</p><ol><li>Design architecture</li><li>Build ViewModel</li><li>Build View</li><li>Add tests</li><li>Review and refine</li></ol><p>That’s how experienced developers already work. AI becomes useful when it fits into that workflow instead of replacing it.</p><h3>Final thought</h3><p>AI is not exposing who can write prompts.</p><p>It is exposing who can think clearly.</p><p>The developers getting real value from AI are not the ones asking it to do everything. They are the ones who know how to break work into smaller parts, define constraints, and properly judge the output.</p><p>That’s the real skill now.</p><p>Not just coding faster.</p><p>Thinking better.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fedfac1dd2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EmoteTrack — How Tracking My Emotions Helped Me Build a Better App]]></title>
            <link>https://medium.com/@sabihhida88/emotetrack-how-tracking-my-emotions-helped-me-build-a-better-app-69374d482520?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/69374d482520</guid>
            <category><![CDATA[journaling]]></category>
            <category><![CDATA[ios-apps]]></category>
            <category><![CDATA[self-awareness]]></category>
            <category><![CDATA[ios-developer]]></category>
            <category><![CDATA[mental-health]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Wed, 31 Dec 2025 12:58:47 GMT</pubDate>
            <atom:updated>2025-12-31T12:58:47.354Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tffS9TuQEvHnl-b3cgwrHg.png" /></figure><h3>EmoteTrack — How Tracking My Emotions Helped Me Build a Better App</h3><blockquote>Most days, we ask others how they’re doing. Rarely do we pause and ask ourselves the same question.</blockquote><p>I used to move through my days on autopilot — work, deadlines, conversations, sleep, repeat. Some days felt productive, others heavy, but when I tried to understand <em>why</em>, I had no clear answer. My emotions were influencing my decisions, my focus, and even my relationships, yet I wasn’t paying attention to them.</p><p>That realization became the starting point of <strong>EmoteTrack</strong>.</p><h3>Part 1: The Problem — Living Without Emotional Awareness</h3><p>Like many professionals and builders, I wasn’t unhappy — but I wasn’t fully aware either. Stress blended into routine. Good days passed without reflection. Bad days repeated themselves because I never stopped to analyze them.</p><p>When I looked for mood tracking or mental wellness apps, I found two extremes:</p><ul><li>Apps that were <strong>too clinical and overwhelming</strong></li><li>Apps that were <strong>too shallow to be useful</strong></li></ul><p>What I wanted didn’t exist: a <strong>simple, private, insight-driven mood tracker</strong> that respected my time and emotions.</p><p>So instead of waiting for it, I decided to build it.</p><h3>Part 2: The Solution — Building EmoteTrack</h3><p><strong>EmoteTrack</strong> started as a small personal experiment: <em>What if I could capture how I feel in under 10 seconds a day?</em></p><p>That single question shaped every decision.</p><h3>What EmoteTrack Focuses On</h3><ul><li><strong>Quick daily mood check-ins</strong> — no friction, no pressure</li><li><strong>Optional journaling</strong> — write when you want, skip when you don’t</li><li><strong>Patterns over time</strong> — emotions make more sense when seen together</li><li><strong>Privacy-first design</strong> — your emotions belong to you</li></ul><p>EmoteTrack doesn’t try to diagnose or fix you. It simply helps you notice.</p><h3>Part 3: The Tech &amp; Vision Behind EmoteTrack</h3><p>As a developer, I care deeply about user experience and calm design. EmoteTrack is built with a clean, minimal interface so it feels safe and welcoming — not clinical or noisy.</p><h3>Design Philosophy</h3><ul><li>Calm colors, minimal screens</li><li>No unnecessary notifications</li><li>Emotion-focused UI, not data overload</li></ul><h3>The Bigger Vision</h3><p>This app is just the beginning. The long-term goal is to help people:</p><ul><li>Understand emotional patterns</li><li>Connect moods with habits and routines</li><li>Build emotional intelligence through awareness</li></ul><p>Future versions may include smarter insights, deeper visual analytics, and personalized reflections — always with simplicity at the core.</p><h3>Why Emotional Tracking Matters</h3><p>Tracking emotions isn’t about controlling them. It’s about <strong>understanding them</strong>.</p><p>When you begin to notice patterns, you naturally start making better choices — about work, relationships, rest, and boundaries.</p><p>Self-awareness is a quiet superpower.</p><h3>Final Thoughts</h3><p>EmoteTrack exists because I needed it.</p><p>If you’ve ever felt that your days blur together emotionally — or that stress repeats itself without explanation — this app is for you.</p><p>Sometimes growth starts with a simple question:</p><blockquote>“How do I feel today?”</blockquote><p><em>If this story resonates with you, I’d love to hear your thoughts or feedback.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69374d482520" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Swift Concurrency: From Callbacks to Actors — A Real iOS Use Case]]></title>
            <link>https://medium.com/@sabihhida88/understanding-swift-concurrency-from-callbacks-to-actors-a-real-ios-use-case-5072e958305a?source=rss-100184599811------2</link>
            <guid isPermaLink="false">https://medium.com/p/5072e958305a</guid>
            <category><![CDATA[ios-app-development]]></category>
            <category><![CDATA[swift-5]]></category>
            <category><![CDATA[ios-development]]></category>
            <category><![CDATA[concurrency]]></category>
            <category><![CDATA[asyncawait]]></category>
            <dc:creator><![CDATA[Sabih Hida Tahir]]></dc:creator>
            <pubDate>Tue, 14 Oct 2025 11:53:05 GMT</pubDate>
            <atom:updated>2025-10-14T12:23:22.841Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Swift Concurrency (Part 1): From Callbacks to Actors — A Real iOS Use Case</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-fwooMNaeZYvfGlCUkr93w.jpeg" /></figure><p>As an iOS developer, I’ve always found concurrency to be one of the trickiest concepts — not because it’s hard, but because of how easy it is to misuse.<br>Before Swift Concurrency was introduced, our apps were filled with <strong>completion handlers, GCD, and Dispatch Queues</strong>. We juggled between threads, trying to make sure the UI didn’t freeze while background tasks ran.</p><p>But with <strong>Swift Concurrency</strong>, Apple changed the game. Let’s break it down with a <strong>real-world example</strong></p><h4>Before Swift Concurrency — The Callback Chaos</h4><p>Imagine we’re building an app. We need to fetch metadata for videos asynchronously.</p><pre>func fetchVideoData(completion: @escaping (Result&lt;Video, Error&gt;) -&gt; Void) {<br>    DispatchQueue.global().async {<br>        let url = URL(string: &quot;https://api.example.com/video&quot;)!<br>        let data = try? Data(contentsOf: url)<br>        let video = try? JSONDecoder().decode(Video.self, from: data!)<br>        <br>        DispatchQueue.main.async {<br>            completion(.success(video!))<br>        }<br>    }<br>}</pre><p>✅ It works. ❌ But it’s messy.<br>We’re managing threads manually, and one missed DispatchQueue.main.async can freeze the UI.<br>Testing this code or chaining multiple calls quickly becomes a nightmare.</p><h4>⚙️ Enter Swift Concurrency — async / await</h4><p>With modern Swift, we can write this much more cleanly:</p><pre>func fetchVideoData() async throws -&gt; Video {<br>    let url = URL(string: &quot;https://api.example.com/video&quot;)!<br>    let (data, _) = try await URLSession.shared.data(from: url)<br>    return try JSONDecoder().decode(Video.self, from: data)<br>}</pre><p>✅ No callbacks.<br>✅ No thread management.<br>✅ Readable like synchronous code, but still asynchronous.</p><p>Now, Swift automatically handles suspension and resumption points behind the scenes.</p><h4>🧠 Real-World Problem: Data Race in Shared State</h4><p>Let’s say you’re building a <strong>shopping or streaming app</strong> where multiple API calls run in parallel — one fetching user info, another fetching recommendations, and a third updating watch history.</p><p>Each of these tasks updates a shared AppState or UserSession object that stores the user’s preferences or progress.</p><p>Before Swift Concurrency, we usually handled this like:</p><pre>class UserSession {<br>    var userInfo: User?<br>    var recommendations: [Video] = []<br>}<br><br>let session = UserSession()<br><br>DispatchQueue.global().async {<br>    session.userInfo = fetchUserInfo() // API Call 1<br>}<br><br>DispatchQueue.global().async {<br>    session.recommendations = fetchRecommendations() // API Call 2<br>}</pre><p>This looks fine, right?<br>But here’s the catch — <strong>both tasks might modify the same </strong><strong>session object simultaneously</strong>, leading to data corruption or crashes.<br>This is what we call a <strong>data race</strong>.</p><h4>💪 The Actor Solution</h4><p>Actors in Swift provide <strong>data isolation</strong>.<br>Each actor ensures that only <strong>one task at a time</strong> can access its mutable state, automatically preventing race conditions.</p><pre>actor UserSession {<br>    var userInfo: User?<br>    var recommendations: [Video] = []<br><br>    func updateUserInfo(_ info: User) {<br>        userInfo = info<br>    }<br><br>    func updateRecommendations(_ items: [Video]) {<br>        recommendations = items<br>    }<br>}</pre><p>Now every update to UserSession is isolated — Swift automatically ensures that no two updates happen simultaneously.</p><pre>let session = UserSession()<br><br>Task {<br>    await session.updateUserInfo(fetchUserInfo())<br>}<br><br>Task {<br>    await session.updateRecommendations(fetchRecommendations())<br>}</pre><p>✅ <strong>No data race</strong>,<br>✅ <strong>Clean async code</strong>,<br>✅ <strong>Automatic safety through actor isolation.</strong></p><p>Your app state is now <strong>thread-safe by design</strong> — using modern concurrency tools instead of manual synchronization.</p><p>But wait — what about the <strong>data</strong> we’re passing <em>into</em> the actor (User and Video)?<br>If those types internally reference mutable data or shared memory, two threads could still modify the same data concurrently.</p><h3>What about Sendable?</h3><p>Sendable ensures that data passed across concurrency boundaries (like tasks or actors) is <strong>thread-safe</strong>.</p><pre>struct User: Sendable {<br>    let id: Int<br>    let name: String<br>}<br><br>struct Video: Sendable {<br>    let id: Int<br>    let title: String<br>}</pre><p>If you mark your types as Sendable, the compiler guarantees that they can safely move between concurrent contexts — giving you <strong>compile-time protection</strong> instead of runtime crashes.</p><h3>🧠 Final Thought</h3><p>In modern Swift Concurrency, async/await, Task, actor, and Sendable aren’t isolated concepts — they <strong>complete each other</strong>:</p><p><strong>async/await</strong> makes asynchronous code <em>readable and sequential</em>, turning callback-heavy logic into a clean, linear flow.</p><p><strong>Task</strong> handles <em>structured concurrency</em> — how and where asynchronous work runs.</p><p><strong>actor</strong> ensures <em>shared-state safety</em> — only one task can mutate a property at a time.</p><p><strong>Sendable</strong> enforces <em>data-transfer safety</em> — values passed between tasks are immutable and safe.</p><p>🧩 <strong>Together</strong>, they form the complete picture of <strong>safe, predictable, and modern concurrency</strong> in Swift.</p><p>You can think of an actor as the bridge between Task-level parallelism and Sendable-level data safety —<br>ensuring that your async code not only runs fast but stays <strong>correct, clean, and crash-free</strong>. 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5072e958305a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>