Skip to content

LucaBonamino/cli-tools

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cli-tools

A collection of lightweight, self-contained command-line utilities written in C. Each tool is a single .c file in src/, designed for easy compilation and instant use. Perfect for UNIX-style workflows—just build, drop into ~/.local/bin (or /usr/local/bin), and run from anywhere.

Avaiable tools

  1. src/replace_spaces.c
    Rename files by replacing spaces with underscores.

  2. src/hashsum.c
    Compute a hash of input text using one of these algorithms:

    • crc32
    • sha256
    • sha512
    • sha1
    • md5
    • poseidon

Installation

Each tool is a single .c file in src/. To compile and install:

# 1. Compile (example for replace_spaces.c)
gcc -O2 -Wall -o replace_spaces src/replace_spaces.c

# 2a. Install system‐wide (requires sudo)
sudo mv replace_spaces /usr/local/bin/

# 2b. Or install just for your user
mkdir -p ~/.local/bin
mv replace_spaces ~/.local/bin

Usage

Replace spaces

replace_spaces --help
Usage: rename_spaces [-v|--verbose] [-d|--dir <directory>] [filename]
  • filename: filename of file whose name to modify.
  • directory: directory where to locate the files whose names are to be modified.

If both filename and directory are provided, directory is discarded.

Hashsum

Hash a text of the content of a file with one of the following alorithms

  • crc32
  • sha256
  • sha1
  • md5
  • poseidon

compile with

gcc -O2 -Wall -o hashsum src/hashsum.c -lssl -lcrypto -lz

execute

hashsum --help
Usage: ./hashsum [-a|--algorithm <sha1|sha256|sha512|md5|poseidon|checksum>] [-f|--file <filename>] [text]
  • text: text to hash.
  • algorithm: hashing algorithm to use.
    • checksum: crc32
    • sha256
    • sha1
    • md5
    • poseidon sponge-like hash
  • file: file to hash.

If both text and file are provided, file is discarded.

How to use Poseidon hash

Get the poseidon required files from the repository c-reference-signer.

git clone https://github.com/MinaProtocol/c-reference-signer.git

Compile hashsum.c providing the poseidon and crypto files

gcc -O2 -Wall \
    -I./c-reference-signer \
    -o hashsum \
    src/hashsum.c \
    c-reference-signer/poseidon.c         \
    c-reference-signer/crypto.c           \
    c-reference-signer/pasta_fp.c         \
    c-reference-signer/pasta_fq.c         \
    c-reference-signer/base10.c           \
    c-reference-signer/base58.c           \
    c-reference-signer/blake2b-ref.c      \
    c-reference-signer/curve_checks.c     \
    c-reference-signer/sha256.c           \
    c-reference-signer/utils.c            \
    -lcrypto -lz -lm

About

A set of small, self-contained command-line programs in C.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published