nushell-plugins/nu_plugin_hashes
Jesús Pérez d9ef2f0d5b
Some checks failed
Build and Test / Validate Setup (push) Has been cancelled
Build and Test / Build (darwin-amd64) (push) Has been cancelled
Build and Test / Build (darwin-arm64) (push) Has been cancelled
Build and Test / Build (linux-amd64) (push) Has been cancelled
Build and Test / Build (windows-amd64) (push) Has been cancelled
Build and Test / Build (linux-arm64) (push) Has been cancelled
Build and Test / Security Audit (push) Has been cancelled
Build and Test / Package Results (push) Has been cancelled
Build and Test / Quality Gate (push) Has been cancelled
Nightly Build / Check for Changes (push) Has been cancelled
Nightly Build / Validate Setup (push) Has been cancelled
Nightly Build / Nightly Build (darwin-amd64) (push) Has been cancelled
Nightly Build / Nightly Build (darwin-arm64) (push) Has been cancelled
Nightly Build / Nightly Build (linux-amd64) (push) Has been cancelled
Nightly Build / Nightly Build (windows-amd64) (push) Has been cancelled
Nightly Build / Nightly Build (linux-arm64) (push) Has been cancelled
Nightly Build / Create Nightly Pre-release (push) Has been cancelled
Nightly Build / Notify Build Status (push) Has been cancelled
Nightly Build / Nightly Maintenance (push) Has been cancelled
chore: update all plugins to Nushell 0.111.0
- Bump all 18 plugins from 0.110.0 to 0.111.0
  - Update rust-toolchain.toml channel to 1.93.1 (nu 0.111.0 requires ≥1.91.1)

  Fixes:
  - interprocess pin =2.2.x → ^2.3.1 in nu_plugin_mcp, nu_plugin_nats, nu_plugin_typedialog
    (required by nu-plugin-core 0.111.0)
  - nu_plugin_typedialog: BackendType::Web initializer — add open_browser: false field
  - nu_plugin_auth: implement missing user_info_to_value helper referenced in tests

  Scripts:
  - update_all_plugins.nu: fix [package].version update on minor bumps; add [dev-dependencies]
    pass; add nu-plugin-test-support to managed crates
  - download_nushell.nu: rustup override unset before rm -rf on nushell dir replace;
    fix unclosed ) in string interpolation
2026-03-11 03:22:42 +00:00
..
2025-06-27 02:31:23 +01:00
2025-06-27 02:31:23 +01:00

Hashes for Nushell

A Nushell plugin that adds a collection of 63 cryptographic hash functions from Hashes project.

This plugin's implementation is based on code stolen from the official Nushell repository and on compile-time code generation with a build script.

Excess algorithms can be filtered off by selecting only specific features of the crate.

Installation

To install this plugin with all algorithms available run

nu
cargo install nu_plugin_hashes
plugin add ($env.CARGO_HOME ++ /bin/nu_plugin_hashes)

or on Windows

nu
cargo install nu_plugin_hashes
plugin add ($env.CARGO_HOME ++ /bin/nu_plugin_hashes.exe)

After loading the plugin, execute help hash to list newly added commands

nu
~> help hash
Apply hash function.

...

Subcommands:
  hash ascon - Hash a value using the ascon hash algorithm.
  hash ascon-a - Hash a value using the ascon-a hash algorithm.
  hash belt - Hash a value using the belt hash algorithm.
  hash blake2b-512 - Hash a value using the blake2b-512 hash algorithm.
  hash blake2s-256 - Hash a value using the blake2s-256 hash algorithm.
  hash fsb160 - Hash a value using the fsb160 hash algorithm.
  hash fsb224 - Hash a value using the fsb224 hash algorithm.
  ...

Features

If you only need some algorithms, disable default features and select only those you need

nu
cargo install nu_plugin_hashes --no-default-features --features sha2,streebog

Then check what's installed

nu
~> help hash
Apply hash function.

...

Subcommands:
  hash md5 - Hash a value using the md5 hash algorithm.
  hash sha224 - Hash a value using the sha224 hash algorithm.
  hash sha256 - Hash a value using the sha256 hash algorithm.
  hash sha384 - Hash a value using the sha384 hash algorithm.
  hash sha512 - Hash a value using the sha512 hash algorithm.
  hash sha512-224 - Hash a value using the sha512-224 hash algorithm.
  hash sha512-256 - Hash a value using the sha512-256 hash algorithm.
  hash streebog256 - Hash a value using the streebog256 hash algorithm.
  hash streebog512 - Hash a value using the streebog512 hash algorithm.

Flags:
  ...

Hashes

The list of implemented algorithms provided by the plugin can be found in the Hashes project repository.

Almost all algorithms from this project are included in this plugin. The exceptions are MD5 and SHA-256 as they are already present in Nushell, and those algorithms, that don't implement the Digest trait or require additional arguments for them to be run.

If you want to import only particular algorithms, build this plugin with those features, which names correspond to the crates, that supply the algorithms you want. Consult this table to match features with required algorithms.

If you disable the default features and forget to enable at least one of them, the plugin won't compile.

Implemetation details

All the functions are implemented via generic code that I borrowed from Nushell source file generic_digest.rs. Help page for each command is generated with a build script. Hashes of the test text for each example are generated during compilation by this script: the test text is fed to each hashing algorithm, and resulting bytes are inserted into examples. This approach isdifferent from Nushell's implementations, where examples are hardcoded as strings. Then, generated examples are tested with nu-plugin-test-support crate. This ensures that the code in examples always behaves exactly as printed.

TODO

Here is a list of things that could not be implemented with code generation as they don't implement the Digest trait or require additional arguments to be executed. I doubt that I will ever complete this list so you are welcome to contribute.

  • blake2b algorithm with runtime defined output size
  • sha1 algorithm with collision detection

License

This crate is licensed under MIT license.


I only created this plugin to explore compile-time code generation and educate myself on subject of features. The product of my activity terrifies me and I'm surprised it worked out at all.