#hmac #generate #signatures #command-line-tool #url #algorithm #gateway

app hmac-cli

🛠️ A command-line tool for generating HMAC signatures

3 releases

0.1.16 Oct 31, 2024
0.1.15 Oct 31, 2024
0.1.0 Oct 31, 2024

#403 in Command line utilities

Download history 310/week @ 2024-10-28

310 downloads per month

MIT license

19KB
205 lines

Table of Contents↗️

hmac-cli

🛠️ A command-line tool for generating HMAC signatures.


Example

$ hmac -h
Usage: hmac.exe [OPTIONS] --url <URL>

Options:
  -a, --ak <AK>                Access Key ID (can be provided via config file `ak`)
  -s, --sk <SK>                Secret Key (can be provided via config file `sk`)
  -m, --method <METHOD>        Request method (default: POST) [default: POST]
  -u, --url <URL>              Request URL
  -b, --body <BODY>            Request body (JSON format)
  -g, --gateway <GATEWAY>      Gateway type (default: traefik) [default: traefik] [possible values: apisix, traefik, higress]
      --algorithm <ALGORITHM>  HMAC algorithm (default: hmac-sha256) [default: hmac-sha256] [possible values: hmac-sha256, hmac-sha384, hmac-sha512]
  -h, --help                   Print help
  -V, --version                Print version
# Generate an HMAC signature for a POST request
$ hmac --ak <HMAC_AK> --sk <HMAC_SK> --method POST --url https://exmaple.com/api --body "{\"hello\":\"world\"}" --gateway traefik

# AK\SK can be set as environment variables (HMAC_AK\HMAC_SK)
$ hmac --method POST --url https://exmaple.com/api --body "{\"hello\":\"world\"}" --gateway apisix

# AK\SK can be set in a configuration file (~/.hmac/config.toml)
# vi ~/.hmac/config.toml
# HMAC_AK = "<HMAC_AK>"
# HMAC_SK = "<HMAC_SK>"
$ hmac --method POST --url https://exmaple.com/api --body "{\"hello\":\"world\"}" --gateway higress

Dependencies

~11–25MB
~306K SLoC