# HASH ## Visão geral O módulo `hash` fornece utilitários de hash para textos informados diretamente, arquivos, operações HMAC, checksums de arquivos e comparações de hash. ## Comandos da CLI ```bash brutils hash md5 --text hello brutils hash sha1 --text hello brutils hash sha256 --file ./README.md brutils hash sha512 --text hello brutils hash hmac --algo sha256 --key secret --text hello brutils hash checksum --file ./dist/cli.js --algo sha512 brutils hash compare --file ./README.md --algo sha256 --expected ``` ## Ações | Ação | Uso | Descrição | | ---------- | ------------------------------------------------------------------------------------------ | ------------------------------------------------ | | `md5` | `brutils hash md5 (--text \| --file )` | Calcula um hash MD5. | | `sha1` | `brutils hash sha1 (--text \| --file )` | Calcula um hash SHA-1. | | `sha256` | `brutils hash sha256 (--text \| --file )` | Calcula um hash SHA-256. | | `sha512` | `brutils hash sha512 (--text \| --file )` | Calcula um hash SHA-512. | | `hmac` | `brutils hash hmac --algo --key (--text \| --file )` | Calcula um HMAC usando o algoritmo selecionado. | | `checksum` | `brutils hash checksum --file [--algo ]` | Calcula um hash para um arquivo. | | `compare` | `brutils hash compare --expected [--algo ] (--text \| --file )` | Compara um hash calculado com um valor esperado. | ## Opções | Opção | Aplicável a | Tipo | Descrição | | ------------------- | ----------------------------- | ------ | ---------------------------------------------- | | `--text ` | ações de hash | string | Valor informado diretamente para gerar o hash. | | `--file ` | ações de hash | string | Arquivo para gerar o hash. | | `--algo ` | `hmac`, `checksum`, `compare` | string | Nome do algoritmo de hash. | | `--key ` | `hmac` | string | Chave secreta para o HMAC. | | `--expected ` | `compare` | string | Valor de hash esperado. | ## Observações - `compare` retorna o hash calculado, o hash esperado e informa se eles correspondem. - `checksum` usa `sha256` por padrão quando `--algo` é omitido.