<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nour833</title>
    <description>The latest articles on DEV Community by Nour833 (@nour833).</description>
    <link>https://dev.to/nour833</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3887487%2F2f37da97-84a2-42e2-b99f-51677811dc4e.png</url>
      <title>DEV Community: Nour833</title>
      <link>https://dev.to/nour833</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nour833"/>
    <language>en</language>
    <item>
      <title>How I packaged offline AI, Flask, and Cryptography into a single Python executable 🚀</title>
      <dc:creator>Nour833</dc:creator>
      <pubDate>Sun, 19 Apr 2026 15:09:46 +0000</pubDate>
      <link>https://dev.to/nour833/how-i-packaged-offline-ai-flask-and-cryptography-into-a-single-python-executable-205p</link>
      <guid>https://dev.to/nour833/how-i-packaged-offline-ai-flask-and-cryptography-into-a-single-python-executable-205p</guid>
      <description>&lt;p&gt;If you have ever tried to share a complex Python project with a friend or a security analyst, you know the pain.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;You hand them the code, and within five minutes, their terminal is throwing errors about missing &lt;code&gt;pip&lt;/code&gt; packages, conflicting library versions, or broken machine learning dependencies.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;As a Computer Science student, I recently ran into this exact wall while building my open-source digital forensics project, &lt;strong&gt;StegoForge&lt;/strong&gt;. I wanted to build a tool that felt like it belonged in a spy movie—something that could hide AES-encrypted payloads inside the frequency domains of images, videos, and audio files, and hunt them down using artificial intelligence.&lt;/p&gt;

&lt;p&gt;The Python code worked flawlessly. &lt;strong&gt;The distribution was a nightmare.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here is how I engineered an architecture to package &lt;code&gt;numpy&lt;/code&gt;, offline ML models, a web server, and a rich CLI into a single, zero-dependency executable.&lt;/p&gt;




&lt;h2&gt;
  
  
  🕵️‍♂️ The Problem: Fragmented Forensics
&lt;/h2&gt;

&lt;p&gt;If you play CTFs (Capture The Flag) or work in DFIR, you know that extracting hidden data (steganography) usually requires piping together half a dozen unmaintained tools like &lt;code&gt;steghide&lt;/code&gt;, &lt;code&gt;zsteg&lt;/code&gt;, or &lt;code&gt;binwalk&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;I wanted to unify this into one framework.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;[👇 See the cli demo in action]&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcl4ltgwhnalhh34cgsbi.gif" alt=" " width="720" height="657"&gt;
&lt;/h2&gt;

&lt;h2&gt;
  
  
  🛠️ The Tech Stack
&lt;/h2&gt;

&lt;p&gt;To make this work, the application needed to be heavy:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;The Core:&lt;/strong&gt; I used &lt;code&gt;numpy&lt;/code&gt; and &lt;code&gt;scipy&lt;/code&gt; to manipulate JPEG DCT (Discrete Cosine Transform) frequency blocks and audio phase spectrums.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The AI Forensics:&lt;/strong&gt; Instead of relying on cloud APIs, I integrated &lt;code&gt;onnxruntime&lt;/code&gt;. On the very first boot, the app pulls HuggingFace CNN models directly to the local machine, caching them so the spatial anomaly detection runs completely offline.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Visuals:&lt;/strong&gt; I utilized &lt;code&gt;Pillow&lt;/code&gt; to build a diff engine that mathematically compares files and generates amplified, glowing heatmaps of the manipulated pixels.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;The Interfaces:&lt;/strong&gt; I built a modern terminal UI using &lt;code&gt;click&lt;/code&gt; and &lt;code&gt;rich&lt;/code&gt;, but I also embedded a local Flask server that spins up a glassmorphic Web UI with Server-Sent Events (SSE) for live terminal output in the browser.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📦 The Packaging Nightmare
&lt;/h2&gt;

&lt;p&gt;The goal was to allow a user to simply download a binary and run a command like this without ever touching Python:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;stegoforge ctf &lt;span class="nt"&gt;--file&lt;/span&gt; target.png
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I used &lt;strong&gt;PyInstaller&lt;/strong&gt;, but standard PyInstaller breaks when you introduce Flask templates and ML bindings. Here is how I solved it:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; &lt;strong&gt;Hooking the Hidden Imports:&lt;/strong&gt; I had to write custom &lt;code&gt;.spec&lt;/code&gt; files to explicitly tell the compiler to bundle the Flask &lt;code&gt;static&lt;/code&gt; and &lt;code&gt;templates&lt;/code&gt; folders, ensuring the Web UI didn't just crash on launch.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;ONNX Weights:&lt;/strong&gt; Machine learning models are huge. I set up the architecture so the executable remains lightweight, and the heavy ML weights are only downloaded via ONNX once the user explicitly triggers an AI scan.&lt;/li&gt;
&lt;li&gt; &lt;strong&gt;Automated CI/CD:&lt;/strong&gt; I wired up GitHub Actions so that every time I push a new release, it automatically spins up Windows, Ubuntu, and macOS runners, compiles the PyInstaller binaries natively, and drops them into the GitHub releases tab.&lt;/li&gt;
&lt;/ol&gt;




&lt;h2&gt;
  
  
  🚀 The Result
&lt;/h2&gt;

&lt;p&gt;You can now download the tool, run one command, and it will throw RS Analysis, Chi-square tests, AES brute-forcing, and offline AI at a file to blindly rip out the payload.&lt;/p&gt;

&lt;p&gt;Building the steganography algorithms was incredibly fun, but solving the Python deployment puzzle was the real engineering victory.&lt;/p&gt;

&lt;p&gt;🔗 &lt;strong&gt;You can check out the source code, the &lt;code&gt;.spec&lt;/code&gt; files, and the binaries here:&lt;/strong&gt;&lt;br&gt;
👉 &lt;a href="https://github.com/Nour833/StegoForge" rel="noopener noreferrer"&gt;github.com/Nour833/StegoForge&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I am always looking to improve the architecture. If you have any feedback on the codebase, the offline ML integration, or ideas for new carrier formats, I would love to hear them in the comments!&lt;/p&gt;

</description>
      <category>python</category>
      <category>cybersecurity</category>
      <category>opensource</category>
      <category>ai</category>
    </item>
  </channel>
</rss>
