mb_rand 0.2.0

Safe Rust bindings to OpenBSD's arc4random functions
Documentation
# mb-rand

A Rust library crate providing safe bindings to [OpenBSD][openbsd]'s
[arc4random][arc4random_man] functions.

## Features

- `fill_bytes` - Fill a byte array with cryptographically secure random data
- `random_bytes` - Generate a new vector filled with random bytes
- `random_string` - Generate a random string from a character set

## Usage

Add this to your `Cargo.toml`:

```toml
[dependencies]
mb_rand = "0.2.0"
```

### Examples

Fill a byte array with random data:

```rust
use mb_rand::fill_bytes;

fn main() {
    let mut buffer = [0u8; 16];
    fill_bytes(&mut buffer);
    println!("Random bytes: {:?}", buffer);
}
```

Generate a random string:

```rust
use mb_rand::random_string;

fn main() {
    // Generate a random password with letters and numbers
    let charset = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
    let password = random_string(charset, 16);
    println!("Random password: {}", password);
}
```

## Requirements

This crate relies on the host system having [OpenBSD][openbsd]'s
`[arc4random][arc4random_man]` functions available. This is typically the case
on:

- [OpenBSD][openbsd] (native)
- FreeBSD (compatible implementation)
- macOS (compatible implementation)
- Some Linux distributions with libbsd installed

On systems where these functions are not available, you will need to install
the appropriate libraries:

### Ubuntu/Debian

```bash
sudo apt-get install libbsd-dev
```

### Fedora/RHEL/CentOS

```bash
sudo dnf install libbsd-devel
```

## Platform-Specific Configuration

For systems where the [arc4random][arc4random_man] functions need explicit
linking, you may need to create a build script (`build.rs`):

```rust
fn main() {
    println!("cargo:rustc-link-lib=bsd");
}
```

## Safety

This crate provides safe wrappers around the unsafe FFI calls to the
[arc4random][arc4random_man] functions. The underlying
[arc4random][arc4random_man] implementation is considered cryptographically
secure and suitable for generating random data for security-sensitive
applications.

## License

Licensed under an OpenBSD-ISC-style license, see [LICENSE](LICENSE) for details.

[arc4random_man]: https://man.openbsd.org/arc4random
[openbsd]: https://www.openbsd.org/