mirror of
https://github.com/NixOS/nix
synced 2025-06-28 22:01:15 +02:00
* Added SHA-1 support. nix-hash' now has an option
--type sha1' to
select SHA-1 hashing.
This commit is contained in:
parent
73992371a3
commit
7e8961f720
9 changed files with 487 additions and 26 deletions
|
@ -13,13 +13,24 @@ void printHelp()
|
|||
|
||||
void run(Strings args)
|
||||
{
|
||||
HashType ht = htMD5;
|
||||
bool flat = false;
|
||||
|
||||
for (Strings::iterator i = args.begin();
|
||||
i != args.end(); i++)
|
||||
{
|
||||
if (*i == "--flat") flat = true;
|
||||
else if (*i == "--type") {
|
||||
++i;
|
||||
if (i == args.end()) throw UsageError("`--type' requires an argument");
|
||||
if (*i == "md5") ht = htMD5;
|
||||
else if (*i == "sha1") ht = htSHA1;
|
||||
else throw UsageError(format("unknown hash type `%1%'") % *i);
|
||||
}
|
||||
else
|
||||
cout << format("%1%\n") % (string)
|
||||
(flat ? hashFile(*i) : hashPath(*i));
|
||||
cout << format("%1%\n") % (string)
|
||||
(flat ? hashFile(*i, ht) : hashPath(*i, ht));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue