rs-random/README.md

96 lines
No EOL
3 KiB
Markdown

# rs-random
**Secure String Generator**
A blazing-fast Rust command-line tool for generating secure random strings with the tiniest possible footprint.
## Features
- **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
## Security
`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
git clone https://git.caileb.com/Caileb/rs-random.git
cd rs-random
cargo build --release
```
## Usage
```bash
rs-random [LENGTH]
rs-random -l <LENGTH> [-s <SETS>] [-c <COUNT>]
rs-random -h
```
- `LENGTH` &lt;number&gt;: Length of each string (default: `16`)
- `-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
| Name | Description |
| ---------------- | ---------------------------------------- |
| 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 |
| cyrillic-upper | Cyrillic uppercase letters |
| greek-lower | Greek lowercase letters |
| greek-upper | Greek uppercase letters |
| symbols | Extended symbols (©®, ™, €, £, etc.) |
### Examples
Generate a single 32-character string (default sets):
```bash
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
```