getrandom

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

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

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
60 /100 Good
Development Activity 60
Maintenance 16
Community 76
Maturity 60
Momentum 28

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
81 /100 Excellent
Architecture 85
Code Quality 82
Innovation 72
Learning Curve 85

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 17 apps in this directory

Rust
95%
Apache 2.0

obscura

AI Agents · Developer Tools

29,203

A lightweight, stealthy headless browser written in Rust — drop-in compatible with Puppeteer and Playwright, built for AI agents and web scraping at scale.

View details
83
Repo Health
79
Technical
72
Dependency
Built with
Rust 95%
Updated 1 weeks ago
TypeScript
90%
MIT

OpenClaw

AI Agents · AI Assistants

392,894

An open-source AI assistant that runs on your own hardware and meets you in Discord, Slack, WhatsApp, iMessage, Telegram, and 20+ other channels, with native apps for every major platform.

View details
88
Repo Health
88
Technical
66
Dependency
Built with
TypeScript 90%
Updated 5 days ago
Python
73%
AGPL 3.0

OpenViking

AI Development · AI Memory · Databases

40,705

An open-source context database that gives AI agents a unified filesystem for memory, resources, and skills with hierarchical tiered retrieval.

View details
85
Repo Health
75
Technical
64
Dependency
Built with
Python 73%
TypeScript 12%
Rust 11%
Updated 5 days ago
Rust
72%
Apache 2.0

Rivet

AI Agents · Developer Tools

6,326

Stateful actors as a primitive for AI agents, real-time collaboration, and durable execution — with in-memory state, WebSockets, queues, and scheduling built in.

View details
87
Repo Health
81
Technical
64
Dependency
Built with
Rust 72%
TypeScript 25%
Updated 5 days ago
Python
64%
AGPL 3.0

Shadowbroker

Analytics · Monitoring · Security

11,358

Self-hosted OSINT dashboard that fuses 60+ live intelligence feeds — flight tracking, ship AIS, satellites, CCTV, seismic and radio networks — into one real-time map, with an agent-ready command channel for AI co-analysts.

View details
85
Repo Health
83
Technical
71
Dependency
Built with
Python 64%
TypeScript 32%
Updated 6 days ago
Rust
66%
Apache 2.0

Temps

Analytics · Devops · Monitoring

865

A self-hosted Rust PaaS that replaces Vercel, Sentry, PostHog, Pingdom, Resend, and E2B with one binary — plus 440+ CLI operations agents like Claude Code can drive directly.

View details
81
Repo Health
86
Technical
66
Dependency
Built with
Rust 66%
TypeScript 33%
Updated 6 days ago
Python
50%
AGPL 3.0

VoiceStudio

Mcp · Music Audio · Voice AI

83,641

Open-source, fully local ElevenLabs alternative for voice cloning, voice design, video dubbing, dictation, transcription and audiobooks, with a local API and MCP server for agents.

View details
86
Repo Health
83
Technical
70
Dependency
Built with
Python 50%
JavaScript 22%
TypeScript 21%
Updated 5 days ago
TypeScript
50%
Other

World Monitor

Analytics · Monitoring

89,376

Real-time global intelligence dashboard that fuses AI-synthesized news, geopolitical risk scoring, and infrastructure tracking into one open-source situational awareness platform.

View details
87
Repo Health
89
Technical
68
Dependency
Built with
TypeScript 50%
JavaScript 48%
Updated 5 days 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