<?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: Be Lead</title>
    <description>The latest articles on DEV Community by Be Lead (@be_lead_d22a0e9b7aff2635b).</description>
    <link>https://dev.to/be_lead_d22a0e9b7aff2635b</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3352858%2Fb6b79bde-0b68-4f23-ab89-03debd475401.png</url>
      <title>DEV Community: Be Lead</title>
      <link>https://dev.to/be_lead_d22a0e9b7aff2635b</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/be_lead_d22a0e9b7aff2635b"/>
    <language>en</language>
    <item>
      <title>How I wrote a Mega.nz downloader with zero dependencies</title>
      <dc:creator>Be Lead</dc:creator>
      <pubDate>Tue, 24 Nov 2026 12:31:33 +0000</pubDate>
      <link>https://dev.to/be_lead_d22a0e9b7aff2635b/how-i-wrote-a-meganz-downloader-with-zero-dependencies-29id</link>
      <guid>https://dev.to/be_lead_d22a0e9b7aff2635b/how-i-wrote-a-meganz-downloader-with-zero-dependencies-29id</guid>
      <description>&lt;p&gt;I wanted to download Mega links on a Mac without installing a Java runtime, so I wrote &lt;a href="https://github.com/gianbenve95/megaget" rel="noopener noreferrer"&gt;MegaGet&lt;/a&gt;: a small Node server plus a local web UI. Here is what turned out to be interesting.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Keys and AES-CTR
&lt;/h2&gt;

&lt;p&gt;A Mega file key is 32 bytes. The AES key is the first half XOR the second half's first 16 bytes, the next 8 bytes are the CTR nonce, and the last 8 are the expected MAC. Because it is plain CTR, you can resume at any 16-byte-aligned offset by setting the counter to &lt;code&gt;offset / 16&lt;/code&gt; and requesting &lt;code&gt;url/&amp;lt;offset&amp;gt;&lt;/code&gt;. That gives you resume after a dropped connection for free.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Verifying the file with &lt;code&gt;aes-128-cbc&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;Mega's integrity check is a chunked CBC-MAC (chunks of 128 KB growing to 1 MB). It maps neatly onto Node's &lt;code&gt;aes-128-cbc&lt;/code&gt; with no padding: encrypt the chunk with the nonce as IV and keep the last block as the chunk MAC. Fold the chunk MACs the same way, then XOR the halves to get the 8-byte tag. No per-block loop needed, so it is fast.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. The 402 and the hashcash challenge
&lt;/h2&gt;

&lt;p&gt;Logging in returned &lt;code&gt;HTTP 402&lt;/code&gt; with an &lt;code&gt;X-Hashcash&lt;/code&gt; header. The client has to find a 4-byte nonce so that SHA-256 of &lt;code&gt;nonce + token x 262144&lt;/code&gt; falls under a threshold, then resend the &lt;em&gt;same&lt;/em&gt; request (same &lt;code&gt;id&lt;/code&gt;) with &lt;code&gt;X-Hashcash: 1:&amp;lt;token&amp;gt;:&amp;lt;nonce&amp;gt;&lt;/code&gt;. I run the search on four &lt;code&gt;worker_threads&lt;/code&gt;; it takes a couple of seconds.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. What it does not do
&lt;/h2&gt;

&lt;p&gt;It does not bypass Mega's transfer quota. When the quota is hit it waits and resumes; with a Mega account it uses that account's quota. It is download-only, and so far tested mostly against a mock Mega server, so real-world bug reports are very welcome.&lt;/p&gt;

&lt;p&gt;Code (MIT): &lt;a href="https://github.com/gianbenve95/megaget" rel="noopener noreferrer"&gt;https://github.com/gianbenve95/megaget&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I wrote it with Claude's help and reviewed and tested the result.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>opensource</category>
    </item>
    <item>
      <title>300 CLI tools, zero dependencies: what Node's standard library can do</title>
      <dc:creator>Be Lead</dc:creator>
      <pubDate>Tue, 24 Nov 2026 12:28:08 +0000</pubDate>
      <link>https://dev.to/be_lead_d22a0e9b7aff2635b/200-cli-tools-zero-dependencies-what-nodes-standard-library-can-do-4n8c</link>
      <guid>https://dev.to/be_lead_d22a0e9b7aff2635b/200-cli-tools-zero-dependencies-what-nodes-standard-library-can-do-4n8c</guid>
      <description>&lt;p&gt;I wanted one command for the small chores I kept googling, so I built &lt;a href="https://github.com/gianbenve95/tinytools" rel="noopener noreferrer"&gt;tinytools&lt;/a&gt;: 300 offline utilities behind &lt;code&gt;tt&lt;/code&gt;, written with only Node's standard library. A few things I learned.&lt;/p&gt;

&lt;h2&gt;
  
  
  TOTP in 15 lines
&lt;/h2&gt;

&lt;p&gt;A TOTP code is an HMAC-SHA1 of the current 30-second counter, "dynamically truncated" to 6 digits. With &lt;code&gt;crypto.createHmac&lt;/code&gt; it fits in a screen, and the RFC 6238 test vectors (time 59, 8 digits gives &lt;code&gt;94287082&lt;/code&gt;) make a perfect test.&lt;/p&gt;

&lt;h2&gt;
  
  
  Cron: the day-of-month OR day-of-week rule
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;0 12 13 * 5&lt;/code&gt; doesn't mean "Friday the 13th": when both day fields are restricted, cron fires when &lt;em&gt;either&lt;/em&gt; matches. It's easy to get this wrong, so there's a test with a known calendar for it.&lt;/p&gt;

&lt;h2&gt;
  
  
  A calculator without &lt;code&gt;eval&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tt calc&lt;/code&gt; is a recursive-descent parser: numbers, &lt;code&gt;+ - * / % ^&lt;/code&gt;, parentheses and a short function list. Inputs like &lt;code&gt;process.exit()&lt;/code&gt; are simply "unknown token".&lt;/p&gt;

&lt;h2&gt;
  
  
  The bug that only showed up on macOS CI
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;tt list&lt;/code&gt; printed fine on my machine but was truncated in the macOS CI. The cause: &lt;code&gt;process.exit(code)&lt;/code&gt; right after a large write to a pipe. Setting &lt;code&gt;process.exitCode&lt;/code&gt; and letting Node exit on its own flushes stdout first.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tests as the real deliverable
&lt;/h2&gt;

&lt;p&gt;Three hundred tools means three hundred places to be quietly wrong. Each tool has tests with independently known answers (Easter 2026 is April 5, the ISO week of 2021-01-03 is 2020-W53, a 200k loan at 3.5% over 30 years is 898.09 per month). Several of my own expected values were wrong too: an independent check (Python) settled which side was right.&lt;/p&gt;

&lt;h2&gt;
  
  
  What it isn't
&lt;/h2&gt;

&lt;p&gt;It doesn't replace &lt;code&gt;jq&lt;/code&gt; or &lt;code&gt;csvkit&lt;/code&gt;; it's the install-free toolbox for the 80% case. It downloads nothing, phones home to no one, and only changes files when you pass an explicit flag.&lt;/p&gt;

&lt;p&gt;I wrote it with Claude's help and reviewed and tested the result. Code (MIT): &lt;a href="https://github.com/gianbenve95/tinytools" rel="noopener noreferrer"&gt;https://github.com/gianbenve95/tinytools&lt;/a&gt;&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>opensource</category>
      <category>cli</category>
    </item>
  </channel>
</rss>
