getrandom

A small, cross-platform Rust crate for retrieving random bytes directly from the OS

Library
Cargo
v0.4.3
573stars
MIT OR Apache-2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
64/100Good
Development Activity68
Maintenance24
Community76
Maturity60
Momentum28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
81/100Excellent
Architecture85
Code Quality82
Innovation72
Learning Curve85

getrandom is a minimal-dependency Rust crate that provides a single, uniform interface for filling a buffer with random bytes sourced from the underlying operating system’s secure random number generator. It abstracts the differences between platform-specific APIs - getrandom(2)//dev/urandom on Linux, BCryptGenRandom on Windows, getentropy on macOS/BSD, and WASI/wasm-bindgen paths for WebAssembly - behind one getrandom::fill() call. Maintained by the Rand Project, it’s a foundational dependency underpinning much of the Rust cryptography and randomness ecosystem, including the rand crate itself.

What You Get

  • A single fill() function (plus a fallible try_fill() variant) that populates a byte slice with cryptographically secure random data from the OS
  • Platform backend implementations for Linux, Windows, macOS, the BSDs, WASI, and wasm32 targets (via an opt-in wasm_js feature) unified behind one public API
  • no_std compatibility, making it usable in embedded and other environments without the Rust standard library
  • An optional sys_rng feature exposing a SysRng type compatible with the rand_core traits for integration with the broader rand ecosystem
  • An Error type with no_std-friendly error codes plus an optional std-feature conversion to std::io::Error

Common Use Cases

  • Generating cryptographic key material, nonces, or salts that need to come directly from the OS’s secure randomness source rather than a userspace PRNG
  • Seeding a higher-level PRNG (such as those in the rand crate) with OS entropy at program startup
  • Sourcing random bytes in no_std or embedded Rust environments where the standard library isn’t available
  • Getting random bytes in a WebAssembly target, using the wasm_js feature to call into the browser’s crypto.getRandomValues under the hood

Under The Hood

Architecture The crate’s public surface lives almost entirely in the 159-line src/lib.rs, which declares the fill/try_fill functions and re-exports the Error type from src/error.rs; the actual platform dispatch happens in src/backends.rs, which uses cfg-if-driven conditional compilation to select the correct backend module (Linux’s getrandom(2) syscall, Windows’ BCryptGenRandom, macOS/BSD getentropy, WASI, or the optional wasm-bindgen path) at compile time rather than runtime, so there is zero dispatch overhead per call. src/sys_rng.rs layers an optional rand_core-compatible SysRng type on top of the same backend calls for crates that want to plug directly into the rand ecosystem’s trait hierarchy. build.rs handles target-specific build-time configuration (detecting libc features, WASM target variants) needed to pick the right backend at compile time. Tech Stack Pure Rust, edition 2024, with cfg-if as effectively the only unconditional dependency; wasm-bindgen/js-sys and rand_core are opt-in via Cargo features (wasm_js, sys_rng) rather than defaults, keeping the dependency footprint minimal for the common non-WASM case. The crate is no_std-compatible by default, with std gated behind an explicit feature flag. Code Quality The tests/ directory is small (2 files) since most of the real testing burden is platform-matrix CI rather than unit tests of pure logic — there’s little application logic to unit test beyond backend dispatch — supplemented by a separate custom_impl_test and nopanic_check crate in the repo root that verify the custom-backend override mechanism and confirm the fast path is panic-free. Given the crate’s small, security-sensitive surface, the low line count itself is a quality signal: less code means less to audit. API Design The API is deliberately reduced to essentially one call (getrandom::fill(&mut buf)), which is about as low-friction as a public API can get; the tradeoff is that feature flags (std, wasm_js, sys_rng) and backend-override mechanisms via getrandom_backend cfg require reading the docs for anything beyond the default case, which is appropriate for a foundational crate whose users are mostly other libraries rather than end applications.

Used by 13 apps in this directory

TypeScript
51%
MIT

Anarlog

Note Taking · AI Assistants · Productivity

9,087

Anarlog is an open-source, local-first AI meeting notetaker that records, transcribes, and summarizes meetings entirely on your device — no cloud lock-in, no mandatory account, and every note saved as a plain markdown file you own forever.

View details
86
Repo Health
77
Technical
69
Dependency
Built with
TypeScript51%
Rust38%
Updated today
TypeScript
75%
GPL 3.0

Bramble

Password Manager · Security · Authentication

315

Local-first, end-to-end encrypted password manager that syncs your vault directly between your own devices over a private peer-to-peer mesh — no server, no account, no cloud in the middle.

View details
73
Repo Health
84
Technical
72
Dependency
Built with
TypeScript75%
Updated today
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
Go
32%
Apache 2.0

CubeSandbox

Developer Tools · Security · AI Agents

11,247

Instant, concurrent, hardware-isolated MicroVM sandboxes for AI agents — E2B-API compatible, sub-60ms cold starts, and a built-in zero-trust egress proxy, all self-hostable at scale.

View details
83
Repo Health
88
Technical
63
Dependency
Built with
Go32%
Rust31%
C21%
Updated today
TypeScript
72%
Other

Epicenter

Knowledge Management · Note Taking · Developer Tools

4,761

A local-first monorepo led by Whispering, an open-source speech-to-text app, built on an MIT toolkit that turns your data into plain Markdown and SQLite files you own instead of a database you rent.

View details
88
Repo Health
90
Technical
68
Dependency
Built with
TypeScript72%
Svelte15%
Updated today
Rust
50%
Other

hoodik

File Storage · Security

1,446

Self-hosted, end-to-end encrypted cloud storage with browser-based encryption and S3-compatible storage support

View details
74
Repo Health
71
Technical
65
Dependency
Built with
Rust50%
TypeScript33%
Vue15%
Updated 4 days ago
JavaScript
57%
Other

Lokus

Note Taking · Knowledge Management

774

Local-first note-taking with graph view, canvas & AI plugins—your Markdown files, zero telemetry, blazing-fast Rust performance.

View details
78
Repo Health
75
Technical
65
Dependency
Built with
JavaScript57%
HTML24%
Updated 1 weeks ago
Rust
72%
Apache 2.0

mesh-llm

AI Development · AI Agents

3,258

Mesh LLM pools GPUs and memory across every machine you own into one OpenAI-compatible API, so agents tap distributed compute instead of a single GPU box or a metered cloud bill.

View details
83
Repo Health
91
Technical
70
Dependency
Built with
Rust72%
TypeScript16%
Updated today
TypeScript
88%
MIT

Mistle

AI Agents · Developer Tools

89

Self-hostable platform for running autonomous coding agents in isolated, credentialless sandboxes with brokered credentials, reusable snapshots, and event-driven triggers.

View details
71
Repo Health
76
Technical
71
Dependency
Built with
TypeScript88%
Rust11%
Updated 1 months ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search