Skip to content

kszongic/string-hash-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

@kszongic/string-hash-cli 🔐

Hash strings from the command line using MD5, SHA-1, SHA-256, or SHA-512. Zero dependencies. Works on Windows, macOS, and Linux.

npm version npm downloads license node zero dependencies platform

Why?

Need a quick hash of a string? You could write a one-liner in Python or pipe through shasum — but the syntax is different on every platform, and you always forget the flags.

string-hash-cli gives you one command that works everywhere:

npx @kszongic/string-hash-cli "hello world"
# b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

No Python. No platform-specific flags. Just the hash.

Install

npm install -g @kszongic/string-hash-cli

Or run directly without installing:

npx @kszongic/string-hash-cli "hello world"

Usage

Hash a string (default: SHA-256, hex)

string-hash "hello world"
# b94d27b9934d3e08a52e52d7da7dabfac484efe37a5380ee9088f7ace2efcde9

Choose your algorithm

# MD5
string-hash -a md5 "test"
# 098f6bcd4621d373cade4e832627b4f6

# SHA-1
string-hash -a sha1 "data"
# a17c9aaa61e80a1bf71d0d850af4e5baa9800bbd

# SHA-512
string-hash -a sha512 "secret"
# bd2b1aaf7ef4f09be9f52ce2d8d599674d81aa9d6a4421696dc4d93dd0619d68...

Base64 output

string-hash -a sha1 -e base64 "data"
# o6a370tOtOSMzGKHmdY9Hxp+sDY=

Hash multiple strings at once

string-hash "one" "two" "three"
# 7692c3ad...  one
# 3fc4ccfe...  two
# 8b5b9db0...  three

Read from stdin

echo -n "secret" | string-hash -a sha512

# Pipe file contents
cat config.json | string-hash -a sha256

# Use in scripts
TOKEN_HASH=$(echo -n "$API_TOKEN" | string-hash)

Options

Flag Description Default
-a, --algorithm <alg> md5, sha1, sha256, sha512 sha256
-e, --encoding <enc> hex, base64 hex
-h, --help Show help
-v, --version Show version

Use Cases

  • Verify data integrity — Quick hash to compare strings or file contents
  • API development — Generate hashes for webhook signatures
  • Password hashing demos — Show how different algorithms produce different outputs
  • CI/CD pipelines — Hash config values for cache keys or artifact naming
  • Shell scripts — Portable hashing without platform-specific sha256sum / shasum / certutil differences
  • Quick checksums — Pipe any input through stdin for an instant hash

Comparison with Alternatives

Feature string-hash-cli shasum (Unix) certutil (Win) openssl dgst Python one-liner
Cross-platform ❌ Unix only ❌ Windows only ⚠️ If installed ⚠️ If installed
Zero dependencies N/A N/A
Multiple algorithms ✅ md5/sha1/256/512 ⚠️ Limited
Multiple strings ✅ One command
Base64 output
Stdin support
Memorable syntax

How It Works

Uses Node.js built-in crypto module — no external dependencies. The entire tool is a thin CLI wrapper around crypto.createHash(), so you get the same battle-tested OpenSSL implementations under the hood.

Related Tools

License

MIT © 2026 kszongic

About

Hash strings from the command line (MD5, SHA1, SHA256, SHA512). Zero deps.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors