ddh 2.0.2

dd's hashing utility


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

ddh, DD's Hashing command utility

ddh is a simple hasher available cross-platform (Windows, macOS, Linux, BSDs) and comes with more features than built-in OS utilities.

Feature Comparison

FeatureddhGNU coreutilsuutils/coreutilsOpenSSL [^3]
Binary mode✔️✔️✔️✔️
Text mode✔️✔️✔️
Check support✔️✔️[^2]✔️✔️
File support✔️✔️✔️✔️
Memory-mapped file support✔️
Standard input (stdin) support✔️✔️✔️✔️
GNU style hashes✔️✔️✔️[^4]✔️
BSD style hashes✔️✔️✔️✔️
SRI style hashes✔️[^5][^5][^5]

Algorithm Availability Comparison

Checksum/HashddhGNU coreutilsuutils/coreutilsOpenSSL[^3]
CRC-32✔️
CRC-64-ISO✔️
CRC-64-ECMA✔️
MurmurHash3✔️
MD5✔️✔️✔️✔️
RIPEMD-160✔️✔️✔️
SHA-1✔️✔️✔️✔️
SHA-2✔️✔️✔️✔️
SHA-3/SHAKE✔️✔️✔️
BLAKE2b✔️✔️✔️[^9]✔️
BLAKE2s✔️✔️
BLAKE3[^6]✔️[^9][^8]

Algorithm Security

Checksum/HashTypeSecure
CRC-32Checksum
CRC-64-ISOChecksum
CRC-64-ECMAChecksum
Murmurhash-32Hash
Murmurhash-128-32Hash
Murmurhash-128-64Hash
MD5Hash
RIPEMD-160Hash✔️
SHA-1Hash
SHA-2Hash✔️
SHA-3/SHAKEHash✔️
BLAKE2bHash✔️
BLAKE2sHash✔️

Usage

Format: ddh [options...|--autocheck] [file|--stdin]

With no arguments, the help page is shown.

For a list of options available, use the --help argument.

For a list of supported checksums and hashes, use the --hashes switch.

Hashing a file

$ ddh --md5 LICENSE
1d267ceb3a8d8f75f1be3011ee4cbf53  LICENSE

To select OpenSSL tags for the output, use --tag.

To select SRI for the output, use --sri.

Check list using hash

$ ddh --sha256 -c list
file1: OK
file2: FAILED
2 total: 1 mismatch, 0 not read

To select the tag digest style, use --tag.

Both OpenSSL and GNU/BSD tags are supported.

Check files against a hash digest

$ ddh --sha1 LICENSE -A f6067df486cbdbb0aac026b799b26261c92734a3
LICENSE: OK

Compare files against each other

$ ddh --sha512 --compare LICENSE README.md dub.sdl 
Files 'LICENSE' and 'README.md' are different
Files 'README.md' and 'dub.sdl' are different
Files 'LICENSE' and 'dub.sdl' are different

Automatically check list from extension

$ ddh --autocheck codium_1.73.0.22306_amd64.deb.sha256
codium_1.73.0.22306_amd64.deb: OK

Hash parameters

Some hashes may take optional parameters.

  • BLAKE2: The --key option takes a binary file for keying the hash.
  • Murmurhash3: The --seed option takes an argument literal for seeding the hash.

Hash styles

StyleCLI SwitchExample
GNU1d267ceb3a8d8f75f1be3011ee4cbf53 LICENSE
BSD--tagMD5(LICENSE)= 1d267ceb3a8d8f75f1be3011ee4cbf53
SRI--srimd5-HSZ86zqNj3XxvjAR7ky/Uw==
Plain--plain1d267ceb3a8d8f75f1be3011ee4cbf53

File Pattern Globbing (* vs. '*')

This utility supports file globbing out of the box using std.file.dirEntries.

However, while useful on Windows, most UNIX-like terminals support in-shell globbing. This may behave differently than the dirEntries function.

To force the usage of the embedded globbing mechanism, you may want to use '*' or \*. To disable it, use the -- parameter.

The globbing pattern is further explained on dlang.org.

The default parameters used in dirEntries are:

  • SpanMode: shallow (same-level directory);
  • And followSymlink: true (follows soft symbolic links).

NOTE: The embedded globbing system includes hidden files.

EXAMPLE: A pattern such as src/*.{d,dd}:

  • Matches src/example.d, src/.dd, and src/file.dd;
  • But doesn't match example.d, src/.ddd, and src/.e;
  • Basically all files ending with .d and .dd in the src directory, following symlinks.

Memory-mapped Files

The mmfile mode's performance may vary on systems. Typically, file mode is faster on Windows, and mmfile mode is faster on Linux systems.

The default is file.

Errors

CodeDescription
1CLI error
2No hashes selected or autocheck not used
3Internal error: Unable to initiate hash module with hash
4Failed to set the hash key
5Failed to set the hash seed
6No such file
7Could not determine hash type
9Could not hash text argument
10List is empty
11Unsupported tag format in list due to missing filename
12Internal error: Couldn't continue processing list
15Two or more files are required to compare

Compiling

Compiling requires a recent D compiler and DUB.

To compile a debug build with the default compiler:

dub build

Release recommendation with the LDC compiler:

dub build -b release-nobounds --compiler=ldc2

To compile with GDC, you'll also need gdmd installed.

Authors:
  • dd86k <dd@dax.moe>
Dependencies:
sha3-d, blake2-d
Versions:
2.0.2 2022-Dec-24
2.0.1 2022-Nov-08
2.0.0 2022-Oct-31
1.4.0 2022-Apr-26
1.3.0 2021-Dec-23
Show all 12 versions
Download Stats:
  • 0 downloads today

  • 0 downloads this week

  • 4 downloads this month

  • 19 downloads total

Score:
0.1
Short URL:
ddh.dub.pm