mirror of
https://github.com/NixOS/nix.git
synced 2024-11-22 14:52:55 +00:00
nix hash convert: Add manpage
This commit is contained in:
parent
6f86f87043
commit
9465c8cca1
40
src/nix/hash-convert.md
Normal file
40
src/nix/hash-convert.md
Normal file
@ -0,0 +1,40 @@
|
||||
R""(
|
||||
|
||||
# Examples
|
||||
|
||||
* Convert a hash to `nix32` (a base-32 encoding with a Nix-specific character set).
|
||||
|
||||
```console
|
||||
$ nix hash convert --hash-algo sha1 --to nix32 800d59cfcd3c05e900cb4e214be48f6b886a08df
|
||||
vw46m23bizj4n8afrc0fj19wrp7mj3c0
|
||||
```
|
||||
|
||||
* Convert a hash to [the `sri` format](https://developer.mozilla.org/en-US/docs/Web/Security/Subresource_Integrity) that includes an algorithm specification:
|
||||
|
||||
```console
|
||||
# nix hash convert --hash-algo sha1 800d59cfcd3c05e900cb4e214be48f6b886a08df
|
||||
sha1-gA1Zz808BekAy04hS+SPa4hqCN8=
|
||||
```
|
||||
|
||||
or with an explicit `--to` format:
|
||||
|
||||
```console
|
||||
# nix hash convert --hash-algo sha1 --to sri 800d59cfcd3c05e900cb4e214be48f6b886a08df
|
||||
sha1-gA1Zz808BekAy04hS+SPa4hqCN8=
|
||||
```
|
||||
|
||||
* Assert the input format of the hash:
|
||||
|
||||
```console
|
||||
# nix hash convert --hash-algo sha256 --from nix32 ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=
|
||||
error: input hash 'ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=' does not have the expected format '--from nix32'
|
||||
|
||||
# nix hash convert --hash-algo sha256 --from nix32 1b8m03r63zqhnjf7l5wnldhh7c134ap5vpj0850ymkq1iyzicy5s
|
||||
sha256-ungWv48Bz+pBQUDeXa4iI7ADYaOWF3qctBD/YfIAFa0=
|
||||
```
|
||||
|
||||
# Description
|
||||
|
||||
`nix hash convert` converts hashes from one encoding to another.
|
||||
|
||||
)""
|
@ -150,15 +150,14 @@ struct CmdHashConvert : Command
|
||||
|
||||
std::string description() override
|
||||
{
|
||||
std::string descr( "convert between different hash formats. Choose from: ");
|
||||
auto iter = hashFormats.begin();
|
||||
assert(iter != hashFormats.end());
|
||||
descr += *iter++;
|
||||
while (iter != hashFormats.end()) {
|
||||
descr += ", " + *iter++;
|
||||
}
|
||||
return "convert between hash formats";
|
||||
}
|
||||
|
||||
return descr;
|
||||
std::string doc() override
|
||||
{
|
||||
return
|
||||
#include "hash-convert.md"
|
||||
;
|
||||
}
|
||||
|
||||
Category category() override { return catUtility; }
|
||||
|
Loading…
Reference in New Issue
Block a user