An open API service indexing awesome lists of open source software.

https://github.com/lucabonamino/cli-tools

A set of small, self-contained command-line programs in C.
https://github.com/lucabonamino/cli-tools

c c-language cli-commands cli-tools crc32 file-managment hashing poseidon-hash sha256 sha512

Last synced: 17 days ago
JSON representation

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

Awesome Lists containing this project

README

          

# 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:

```bash
# 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
```bash
replace_spaces --help
Usage: rename_spaces [-v|--verbose] [-d|--dir ] [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
```bash
gcc -O2 -Wall -o hashsum src/hashsum.c -lssl -lcrypto -lz
```
execute
```bash
hashsum --help
Usage: ./hashsum [-a|--algorithm ] [-f|--file ] [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](https://github.com/MinaProtocol/c-reference-signer).
```bash
git clone https://github.com/MinaProtocol/c-reference-signer.git
```

Compile hashsum.c providing the poseidon and crypto files

```bash
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
```