Documentation
¶
Overview ¶
Package root provides core functionality for computing cryptographic hashes of files and stdin. It supports multiple hashing algorithms including BLAKE3, CRC32, MD5, SHA-256, SHA-3 variants, and xxHash, with progress bar display for large files.
Index ¶
- Variables
- func HashFile(ctx context.Context, file FileInfo, active ActiveHashes) ([]hashers.HashResult, error)
- func HashStdin(ctx context.Context, active ActiveHashes) ([]hashers.HashResult, int64, error)
- func WriteOutput(output io.Writer, hashResults []hashers.HashResult, file FileInfo, ...) error
- type ActiveHashes
- type FileInfo
Constants ¶
This section is empty.
Variables ¶
var ErrNoHashResults = errors.New("no hash results")
ErrNoHashResults indicates that no hash results were available or computed.
var ErrNoRecursion = errors.New("cannot hash directory without -r flag")
ErrNoRecursion indicates that directory hashing requires the -r flag to enable recursive processing.
Functions ¶
func HashFile ¶
func HashFile(ctx context.Context, file FileInfo, active ActiveHashes) ([]hashers.HashResult, error)
HashFile computes the hashes for a given file based on the active hashing algorithms. It also displays a progress bar if the file size exceeds a certain threshold.
func HashStdin ¶
func HashStdin(ctx context.Context, active ActiveHashes) ([]hashers.HashResult, int64, error)
HashStdin computes cryptographic hashes of data read from standard input using the specified active hashing configurations. It concurrently updates a progress bar on the terminal during processing. Returns the computed hash results, total bytes read, and any error encountered.
func WriteOutput ¶
func WriteOutput(output io.Writer, hashResults []hashers.HashResult, file FileInfo, uppercase bool) error
WriteOutput writes formatted hash results and file details to the provided io.Writer. It uses tabs and optional uppercase formatting.
Types ¶
type ActiveHashes ¶
type ActiveHashes struct {
DoBlake3 bool
DoCrc32 bool
DoSha256 bool
DoSha3_224 bool
DoSha3_256 bool
DoSha3_384 bool
DoSha3_512 bool
DoMd5 bool
DoXxHash bool
}
ActiveHashes holds flags indicating which hashing algorithms are active.
func ParseActiveHashes ¶
func ParseActiveHashes(cmd *cobra.Command) (ActiveHashes, error)
ParseActiveHashes extracts the active hashing algorithms from the command flags.