aboutsummaryrefslogtreecommitdiffstats
path: root/src/cli
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2018-06-28 09:48:10 -0400
committerJack Lloyd <[email protected]>2018-06-28 09:48:10 -0400
commitad6573bf7b2c7d54b83b8a55d211e0b0132d1b00 (patch)
treec84603cd0980a2c91cd5c247ce8e3bb687416738 /src/cli
parent0346d45fa84108d8d40c32b6944477b96ff52f34 (diff)
Add --no-fsname option to hash cli
Diffstat (limited to 'src/cli')
-rw-r--r--src/cli/utils.cpp10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/cli/utils.cpp b/src/cli/utils.cpp
index f5c914fed..ce2dcede7 100644
--- a/src/cli/utils.cpp
+++ b/src/cli/utils.cpp
@@ -231,7 +231,7 @@ BOTAN_REGISTER_COMMAND("cpuid", Print_Cpuid);
class Hash final : public Command
{
public:
- Hash() : Command("hash --algo=SHA-256 --buf-size=4096 *files") {}
+ Hash() : Command("hash --algo=SHA-256 --buf-size=4096 --no-fsname *files") {}
std::string group() const override
{
@@ -254,6 +254,7 @@ class Hash final : public Command
}
const size_t buf_size = get_arg_sz("buf-size");
+ const bool no_fsname = flag_set("no-fsname");
std::vector<std::string> files = get_arg_list("files");
if(files.empty())
@@ -267,7 +268,12 @@ class Hash final : public Command
{
auto update_hash = [&](const uint8_t b[], size_t l) { hash_fn->update(b, l); };
read_file(fsname, update_hash, buf_size);
- output() << Botan::hex_encode(hash_fn->final()) << " " << fsname << "\n";
+ const std::string digest = Botan::hex_encode(hash_fn->final());
+
+ if(no_fsname)
+ output() << digest << "\n";
+ else
+ output() << digest << " " << fsname << "\n";
}
catch(CLI_IO_Error& e)
{