xhash
— compute
multiple hashes on strings, files, and directories
xhash |
[OPTIONS] [-s STRING ...]
[-c FILE]
[-i FILE]
[FILE ...] [-r
FILE ... DIRECTORY ...] |
xhash
is a Go program that uses goroutines
to calculate multiple hashes on strings, files, and directories. By default,
it reads from standard input.
The output format is fully configurable.
-a
,
--all
- Use all algorithms (except others specified, if any)
-b
,
--base64
- Output hash in Base64 encoding format
--blake2b-256
- Use BLAKE2b-256 algorithm
--blake2b-512
- Use BLAKE2b-512 algorithm
--blake2s-256
- Use BLAKE2s-256 algorithm
--blake3
- Use BLAKE3 algorithm
-c
,
--check
file
- Read checksums from file (use "" for stdin) (default
"\x00")
-f
,
--format
string
- Output format (default "{{range .}}{{.Name}} ({{.File}}) = {{.Sum
}}\n{{end}}")
--gnu
- Use the GNU
md5sum
output format
-H
,
--hmac
key
- Key for HMAC (in hexadecimal) or read from specified pathname (default
"\x00")
--ignore-missing
- Don't fail or report status for missing files
-i
,
--input
file
- Read pathnames from file (use "" for stdin) (default
"\x00")
--md5
- Use MD5 algorithm
-q
,
--quiet
- Don't print OK for each successfully verified file
-r
,
--recursive
- Recurse into directories
--sha1
- Use SHA1 algorithm
--sha256
- Use SHA256 algorithm
--sha3-256
- Use SHA3-256 algorithm
--sha3-512
- Use SHA3-512 algorithm
--sha512
- Use SHA512 algorithm
--sha512-256
- Use SHA512-256 algorithm
--size
- Include file size in output
-S
,
--status
- Don't output anything; status code shows success
--strict
- Exit non-zero for improperly formatted checksum lines
-s
,
--string
- Treat arguments as strings
-L
,
--symlinks
- Follow symbolic links while recursing directories
-v
,
--verbose
- Verbose operation
--version
- Show version and exit
-w
,
--warn
- Warn about improperly formatted checksum lines
-z
,
--zero
- End each output line with NUL, not newline, and disable file name
escaping
To hash every file in your home directory using both SHA-512 and
SHA-256:
xhash -r -sha512 -sha256 $HOME
To hash the /etc/passwd file with all algorithms except MD5 and
SHA-1:
xhash -all -md5 -sha1 /etc/passwd
To hash the string "abc" with all algorithms:
To check the hashes in /tmp/hashes.md5:
To hash all files specified in /tmp/files.list:
The default format is the same as the BSD commands. Use
--gnu
to use the format used by
md5sum
.
To mimic the format used by hashdeep
,
use:
--size -f '{{range .}}{{.Sum}},{{end}}{{(index . 0).File}}\n'