Added hex, speed improvements, size reduction

This commit is contained in:
Caileb 2025-05-28 22:30:59 -05:00
parent ef7473a29e
commit 2558b97e0e
4 changed files with 104 additions and 44 deletions

View file

@ -2,21 +2,30 @@
**Secure String Generator**
A minimal, blazing-fast Rust command-line tool for generating secure random strings with the tiniest possible footprint. Perfect for standalone use or integration into other applications.
A blazing-fast Rust command-line tool for generating secure random strings with the tiniest possible footprint.
## Features
- Uses operating system entropy (`OsRng`) for cryptographically secure randomness
- Very small binary size (optimized release profile)
- Minimal dependencies (only the `rand` crate with `std_rng` and `getrandom` features)
- Flexible selection of character sets, including alphabets, numbers, symbols, and more
- **True cryptographic security**: Uses operating system entropy (`OsRng`) for cryptographically secure randomness
- **Flexible character sets**: Includes alphabets, numbers, symbols, and more
- **Tiny binary size**: Aggressively optimized for size
- **Zero dependencies**: Only uses Rust's `rand` crate with minimal features
## About
## Security
I created `rs-random` to have a super simple, minimal way to generate secure strings that I could build into other applications, ensuring security, speed, and a tiny footprint.
`rs-random` uses `OsRng` from Rust's `rand` crate, which is cryptographically secure and implements the `CryptoRng` trait. It pulls entropy directly from:
- Linux/Unix: `/dev/urandom` (via `getrandom` syscall when available)
- Windows: `CryptGenRandom`
- macOS: `SecRandomCopyBytes`
This is more secure than OpenSSL's `RAND_bytes()` which uses a userland PRNG.
## Installation
### Windows
Download the latest Windows executable from the [releases page](https://git.caileb.com/Caileb/rs-random/releases).
### From Source
```bash
@ -30,14 +39,25 @@ cargo build --release
```bash
rs-random [LENGTH]
rs-random -l <LENGTH> [-s <SETS>] [-c <COUNT>]
rs-random -h | --help
rs-random -h
```
- `LENGTH` &lt;number&gt;: Length of each string (default: `16`)
- `-l, --length <LENGTH>`: Specify the string length
- `-s, --sets <SETS>`: Comma-separated list of character sets to include (default: `lowercase,uppercase,numbers,special-safe`)
- `-c, --count <COUNT>`: Number of strings to generate (default: `1`)
- `-h, --help`: Show help information
- `-l <LENGTH>`: Specify the string length
- `-s <SETS>`: Comma-separated list of character sets to include (default: `lowercase,uppercase,numbers,special-safe`)
- `-c <COUNT>`: Number of strings to generate (default: `1`)
- `-h`: Show help information
### Default Character Sets
When you run `rs-random` without specifying sets, it uses: **lowercase + uppercase + numbers + special-safe**
This gives you a secure password with:
- 26 lowercase letters (a-z)
- 26 uppercase letters (A-Z)
- 10 numbers (0-9)
- 15 safe special characters: `!@#$%^&*_+-=<>?`
- **Total: 77 possible characters per position**
### Available Character Sets
@ -46,6 +66,7 @@ rs-random -h | --help
| lowercase | English lowercase letters (a-z) |
| uppercase | English uppercase letters (A-Z) |
| numbers | Numbers (0-9) |
| hex | Hexadecimal (0-9, a-f) |
| special | Special characters |
| special-safe | Safe special chars (no pipes/brackets) |
| cyrillic-lower | Cyrillic lowercase letters |
@ -62,8 +83,14 @@ Generate a single 32-character string (default sets):
rs-random 32
```
Generate a 32-character hex string (like `openssl rand -hex 16`):
```bash
rs-random -l 32 -s hex
```
Generate five 12-character strings using only lowercase and numbers:
```bash
rs-random -l 12 -s lowercase,numbers -c 5
```
```