mirror of
https://github.com/RGBCube/serenity
synced 2025-05-14 09:04:59 +00:00
checksum: Add support for BLAKE2b
This commit is contained in:
parent
1b3ad1c721
commit
7cb80c67d8
4 changed files with 8 additions and 3 deletions
|
@ -5,6 +5,7 @@ checksum - helper program for calculating checksums
|
||||||
## Synopsis
|
## Synopsis
|
||||||
|
|
||||||
```**sh
|
```**sh
|
||||||
|
$ b2sum [options...] <file...>
|
||||||
$ md5sum [options...] <file...>
|
$ md5sum [options...] <file...>
|
||||||
$ sha1sum [options...] <file...>
|
$ sha1sum [options...] <file...>
|
||||||
$ sha256sum [options...] <file...>
|
$ sha256sum [options...] <file...>
|
||||||
|
@ -14,7 +15,7 @@ $ sha512sum [options...] <file...>
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
This program calculates and print specified checksum of files. It cannot be run directly, only
|
This program calculates and print specified checksum of files. It cannot be run directly, only
|
||||||
as `md5sum`, `sha1sum`, `sha256sum` or `sha512sum`. A non-zero exit code is returned if the
|
as `b2sum`, `md5sum`, `sha1sum`, `sha256sum` or `sha512sum`. A non-zero exit code is returned if the
|
||||||
input cannot be read. If the '--check' option is used, a non-zero exit code is also returned
|
input cannot be read. If the '--check' option is used, a non-zero exit code is also returned
|
||||||
if the checksums cannot be verified.
|
if the checksums cannot be verified.
|
||||||
|
|
||||||
|
|
|
@ -200,6 +200,7 @@ ln -sf /bin/env mnt/usr/bin/env
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
||||||
printf "installing 'checksum' variants... "
|
printf "installing 'checksum' variants... "
|
||||||
|
ln -sf checksum mnt/bin/b2sum
|
||||||
ln -sf checksum mnt/bin/md5sum
|
ln -sf checksum mnt/bin/md5sum
|
||||||
ln -sf checksum mnt/bin/sha1sum
|
ln -sf checksum mnt/bin/sha1sum
|
||||||
ln -sf checksum mnt/bin/sha256sum
|
ln -sf checksum mnt/bin/sha256sum
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include <Userland/Shell/Shell.h>
|
#include <Userland/Shell/Shell.h>
|
||||||
|
|
||||||
#define ENUMERATE_UTILITIES(E, ALIAS) \
|
#define ENUMERATE_UTILITIES(E, ALIAS) \
|
||||||
|
ALIAS(b2sum, checksum) \
|
||||||
E(cat) \
|
E(cat) \
|
||||||
E(checksum) \
|
E(checksum) \
|
||||||
E(chmod) \
|
E(chmod) \
|
||||||
|
|
|
@ -19,7 +19,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
auto program_name = LexicalPath::basename(arguments.strings[0]);
|
auto program_name = LexicalPath::basename(arguments.strings[0]);
|
||||||
auto hash_kind = Crypto::Hash::HashKind::None;
|
auto hash_kind = Crypto::Hash::HashKind::None;
|
||||||
|
|
||||||
if (program_name == "md5sum")
|
if (program_name == "b2sum")
|
||||||
|
hash_kind = Crypto::Hash::HashKind::BLAKE2b;
|
||||||
|
else if (program_name == "md5sum")
|
||||||
hash_kind = Crypto::Hash::HashKind::MD5;
|
hash_kind = Crypto::Hash::HashKind::MD5;
|
||||||
else if (program_name == "sha1sum")
|
else if (program_name == "sha1sum")
|
||||||
hash_kind = Crypto::Hash::HashKind::SHA1;
|
hash_kind = Crypto::Hash::HashKind::SHA1;
|
||||||
|
@ -29,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
||||||
hash_kind = Crypto::Hash::HashKind::SHA512;
|
hash_kind = Crypto::Hash::HashKind::SHA512;
|
||||||
|
|
||||||
if (hash_kind == Crypto::Hash::HashKind::None) {
|
if (hash_kind == Crypto::Hash::HashKind::None) {
|
||||||
warnln("Error: program must be executed as 'md5sum', 'sha1sum', 'sha256sum' or 'sha512sum'; got '{}'", program_name);
|
warnln("Error: program must be executed as 'b2sum', 'md5sum', 'sha1sum', 'sha256sum' or 'sha512sum'; got '{}'", program_name);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue