mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-25 09:00:22 +00:00
checksum: Add support for BLAKE2b
This commit is contained in:
parent
1b3ad1c721
commit
7cb80c67d8
Notes:
sideshowbarker
2024-07-17 00:53:02 +09:00
Author: https://github.com/implicitfield Commit: https://github.com/SerenityOS/serenity/commit/7cb80c67d8 Pull-request: https://github.com/SerenityOS/serenity/pull/21112 Reviewed-by: https://github.com/alimpfard
4 changed files with 8 additions and 3 deletions
|
@ -5,6 +5,7 @@ checksum - helper program for calculating checksums
|
|||
## Synopsis
|
||||
|
||||
```**sh
|
||||
$ b2sum [options...] <file...>
|
||||
$ md5sum [options...] <file...>
|
||||
$ sha1sum [options...] <file...>
|
||||
$ sha256sum [options...] <file...>
|
||||
|
@ -14,7 +15,7 @@ $ sha512sum [options...] <file...>
|
|||
## Description
|
||||
|
||||
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
|
||||
if the checksums cannot be verified.
|
||||
|
||||
|
|
|
@ -200,6 +200,7 @@ ln -sf /bin/env mnt/usr/bin/env
|
|||
echo "done"
|
||||
|
||||
printf "installing 'checksum' variants... "
|
||||
ln -sf checksum mnt/bin/b2sum
|
||||
ln -sf checksum mnt/bin/md5sum
|
||||
ln -sf checksum mnt/bin/sha1sum
|
||||
ln -sf checksum mnt/bin/sha256sum
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
#include <Userland/Shell/Shell.h>
|
||||
|
||||
#define ENUMERATE_UTILITIES(E, ALIAS) \
|
||||
ALIAS(b2sum, checksum) \
|
||||
E(cat) \
|
||||
E(checksum) \
|
||||
E(chmod) \
|
||||
|
|
|
@ -19,7 +19,9 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
auto program_name = LexicalPath::basename(arguments.strings[0]);
|
||||
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;
|
||||
else if (program_name == "sha1sum")
|
||||
hash_kind = Crypto::Hash::HashKind::SHA1;
|
||||
|
@ -29,7 +31,7 @@ ErrorOr<int> serenity_main(Main::Arguments arguments)
|
|||
hash_kind = Crypto::Hash::HashKind::SHA512;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue