<?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: Priyanshu Rav</title>
    <description>The latest articles on DEV Community by Priyanshu Rav (@priyanshurav).</description>
    <link>https://dev.to/priyanshurav</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%2F3841679%2F8de4200a-a6ab-4e2e-8064-494797e07124.png</url>
      <title>DEV Community: Priyanshu Rav</title>
      <link>https://dev.to/priyanshurav</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/priyanshurav"/>
    <language>en</language>
    <item>
      <title>sha256sum, shasum, Get-FileHash — and still no good way to compare hashes</title>
      <dc:creator>Priyanshu Rav</dc:creator>
      <pubDate>Tue, 24 Mar 2026 13:46:57 +0000</pubDate>
      <link>https://dev.to/priyanshurav/sha256sum-shasum-get-filehash-and-still-no-good-way-to-compare-hashes-4mak</link>
      <guid>https://dev.to/priyanshurav/sha256sum-shasum-get-filehash-and-still-no-good-way-to-compare-hashes-4mak</guid>
      <description>&lt;p&gt;I download a file. The website has a SHA-256 hash next to it. I want to verify it. So I run &lt;code&gt;sha256sum&lt;/code&gt;, get a wall of hex, paste the expected hash next to it, and squint at two 64-character strings trying to spot any difference.&lt;/p&gt;

&lt;p&gt;For a quick one-off verification, the native tools are clunky. On Linux it's &lt;code&gt;sha256sum&lt;/code&gt;, on macOS it's &lt;code&gt;shasum -a 256&lt;/code&gt;, on Windows it's &lt;code&gt;Get-FileHash&lt;/code&gt;. Different syntax, same manual effort.&lt;/p&gt;

&lt;p&gt;(Yes, &lt;code&gt;sha256sum -c&lt;/code&gt; exists. But it expects a properly formatted checksum file — not a hash you just copied off a download page.)&lt;/p&gt;

&lt;p&gt;So I ended up building a small CLI for this: &lt;a href="https://www.npmjs.com/package/verify-integrity" rel="noopener noreferrer"&gt;&lt;code&gt;verify-integrity&lt;/code&gt;&lt;/a&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What it does
&lt;/h2&gt;

&lt;p&gt;Instead of just outputting a string or failing quietly, it shows you a character-by-character diff so you can see exactly where they diverge:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;$ npx verify-integrity ./myfile.zip 3a4c9877b483ab46d7c3fbe165a0db275e1ae3cfe56a5657e5a47c2f99a99d1e
✖ Hashes did not match! Integrity verification failed.
   Expected:  3a4c9877b483ab46d7c3fbe165a0db275e1ae3cfe56a5657e5a47c2f99a99d1e
   Generated: 3a4c9877b483ab46d7c3fbe165a0db275e1ae3cfe56a5657e5a47c2f99a99dab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Matching characters are dimmed, mismatching ones are bold. Useful when you're trying to figure out if you fat-fingered something or if the file is genuinely corrupted.&lt;/p&gt;

&lt;p&gt;On a match:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;✔ Hashes matched! Integrity verified.
Generated hash: 3a4c9877b483ab46d7c3fbe165a0db275e1ae3cfe56a5657e5a47c2f99a99d1e
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or, skip saving the file entirely and pipe straight from curl:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-sL&lt;/span&gt; https://example.com/file.zip | verify-integrity - 3a4c9877b483ab46...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Pass &lt;code&gt;-&lt;/code&gt; as the file path and it reads from stdin. Standard Unix convention, works naturally in pipelines.&lt;/p&gt;




&lt;h2&gt;
  
  
  The algorithm situation
&lt;/h2&gt;

&lt;p&gt;SHA-256 is the default since that's what most things use these days, but you can switch:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;verify-integrity &lt;span class="nt"&gt;-a&lt;/span&gt; sha512 ./file.tar.gz 9b71d224bd62f378...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;MD5 and SHA-1 are supported too for legacy stuff, though the README is upfront about the fact that MD5 is broken and SHA-1 is weak. I didn't want to pretend otherwise.&lt;/p&gt;




&lt;h2&gt;
  
  
  Partial hashes
&lt;/h2&gt;

&lt;p&gt;Occasionally you'll see a shortened hash prefix in release notes or some internal tool, not the full hash. The &lt;code&gt;--partial&lt;/code&gt; flag handles that:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;verify-integrity &lt;span class="nt"&gt;-p&lt;/span&gt; ./myfile.zip abcd1234
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It checks whether the generated hash starts with your prefix. There's a warning built in if your prefix is under 8 characters — short enough that false positives become a real concern.&lt;/p&gt;




&lt;h2&gt;
  
  
  For scripting
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;--quiet&lt;/code&gt; kills all output and communicates purely through exit codes. &lt;code&gt;0&lt;/code&gt; for a match, &lt;code&gt;1&lt;/code&gt; for a mismatch.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;verify-integrity &lt;span class="nt"&gt;-q&lt;/span&gt; ./release.tar.gz 3a4c9877b483ab46... &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; deploy.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Drop it into any script or CI pipeline without worrying about parsing output.&lt;/p&gt;




&lt;h2&gt;
  
  
  Should you use it over the native tools?
&lt;/h2&gt;

&lt;p&gt;If the native tools are already muscle memory for you, honestly just keep using them.&lt;/p&gt;

&lt;p&gt;But if you switch between machines, script things cross-platform, or just want a clear pass/fail without the manual comparison — give it a shot. The &lt;code&gt;npx&lt;/code&gt; invocation means you don't even have to commit to installing it.&lt;/p&gt;

&lt;p&gt;It's fully open-source. Feel free to audit the code, fork it, or open an issue over on &lt;a href="https://github.com/priyanshurav/verify-integrity" rel="noopener noreferrer"&gt;GitHub&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Try it yourself:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npx verify-integrity &amp;lt;file&amp;gt; &amp;lt;expected_hash&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Would love to hear what you think.&lt;/p&gt;

</description>
      <category>cli</category>
      <category>linux</category>
      <category>security</category>
      <category>bash</category>
    </item>
  </channel>
</rss>
