getrandom
A small cross-platform library for retrieving random data from system source
0.4.3
1.8B downloads/mo
#3 most downloaded on crates.io
rust-random/getrandom
What this package is like to depend on
Last release 2 months ago
17 Jun 2026
Release timing varies
gaps range from 8 days to 5 months
Nearly every release is documented
notes for 43 of 43 stable releases
2 versions withdrawn
withdrawn after publishing
8 years old
48 releases · first in 2019
8 releases in the last 12 months
see the full history below
Release timeline
48 releases · Jan 2019 to Jun 2026Releases
latest 48-
0.4.317 Jun 2026Release notes
Open source →Added
wasm64-unknown-unknowntarget support forwasm_jsbackend #848
Changed
- Drop
wasip2andwasip3dependencies in favor of manual bindings
#830
Release notes
Open source →Added
wasm64-unknown-unknowntarget support forwasm_jsbackend #848
Changed
- Drop
wasip2andwasip3dependencies in favor of manual bindings #830
-
0.4.203 Mar 2026 -
0.4.103 Feb 2026 -
0.4.002 Feb 2026 -
0.4.0-rc.124 Jan 2026 pre-releaseRelease notes
Open source →- Renames
(Try)RngCore=>(Try)Rng - Replace use of
unwrap_errin example withUnwrapErr
- Renames
-
0.4.0-rc.027 Dec 2025 pre-release -
0.3.414 Oct 2025Release notes
Open source →Forgot this because I'm out of practice.
Signed-off-by: Joe Richey [email protected]
Release notes
Open source →Major change to
wasm_jsbackendNow, when the
wasm_jsfeature is enabled, thewasm_jsbackend will be used by default. Users ofwasm32-unknown-unknowntargeting JavaScript environments like the Web and Node.js will no longer need to specify:--cfg getrandom_backend="wasm_js"in
RUSTFLAGSfor the crate to compile. They can now simple enable a feature.Note: this should not affect non-JS users of the
wasm32-unknown-unknowntarget. Using--cfg getrandom_backendwill still override the source of randomness even if thewasm_jsfeature is enabled. This includes--cfg getrandom_backend=customand--cfg getrandom_backend=unsupported.For more information, see the discussions in #671, #675, and #730.
Added
Changed
- Implement Memory Sanitizer unpoisoning more precisely #678
- Relax MSRV for the
linux_rawopt-in backend on ARM targets #688 - Use
getrandomsyscall on all RISC-V Linux targets #699 - Replaced
wasidependency withwasip2#721 - Enable
wasm_jsbackend by default if thewasm_jsfeature is enabled #730
Removed
- Unstable
rustc-dep-of-stdcrate feature #694
-
0.3.309 May 2025 -
0.3.217 Mar 2025Release notes
Open source →Added
efi_rngopt-in backend #570linux_rawopt-in backend #572.cargo/config.tomlexample in the crate-level docs #591getrandom_test_linux_without_fallbackconfiguration flag to test that file fallback is not triggered in thelinux_android_with_fallbackbackend #605- Built-in support for
*-linux-nonetargets #618 - Cygwin support #626
Changed
- Update
wasidependency to v0.14 #594 - Add
#[inline]attribute to the inner functions #596 - Update WASI and Emscripten links in the crate-level docs #597
- Do not use
dlsymon MUSL targets in thelinux_android_with_fallbackbackend #602 - Remove
linux_android.rsand usegetrandom.rsinstead #603 - Always use
RtlGenRandomon Windows targets when compiling with pre-1.78 Rust #610 - Internal representation of the
Errortype #614 - Remove
windows-targetsdependency and useraw-dylibdirectly #627
Removed
Error::INTERNAL_STARTandError::CUSTOM_STARTassociated constants #614
-
0.3.128 Jan 2025 -
0.3.025 Jan 2025Release notes
Open source →Breaking Changes
Changed
- Bump MSRV to 1.63 #542
- Rename
getrandomandgetrandom_uninitfunctions tofillandfill_uninitrespectively #532
Removed
wasm32-wasitarget support (usewasm32-wasip1orwasm32-wasip2instead) #499linux_disable_fallback,rdrand,js,test-in-browser, andcustomcrate features in favor of configuration flags #504register_custom_getrandom!macro #504- Implementation of
From<NonZeroU32>forErrorandError::codemethod #507 - Internet Explorer 11 support #554
- Target-specific associated
Errorconstants #562
Changed
- Use
ProcessPrngon Windows 10 and up, and useRtlGenRandomon older Windows versions #415 - Do not use locale-specific
strerror_rfor retrieving error code descriptions #440 - Avoid assuming
usizeis the native word size in therdrandbackend #442 - Do not read from
errnowhenlibcdid not indicate error on Solaris #448 - Switch from
libpthread's mutex tofutexon Linux and tonanosleep-based wait loop on other targets in theuse_filebackend #490 - Do not retry on
EAGAINwhile polling/dev/randomon Linux #522 - Remove separate codepath for Node.js in the
wasm_jsbackend (bumps minimum supported Node.js version to v19) #557 - Use
js_namespacein thewasm_jsbackend #559
Added
wasm32-wasip1andwasm32-wasip2support #499getrandom_backendconfiguration flag for selection of opt-in backends #504Error::new_custommethod #507rndropt-in backend #512- Automatic MemorySanitizer support #521 #571
u32andu64functions for generating random values of the respective type #544wasm32v1-nonesupport in thewasm_jsbackend #560wasm_jscrate feature which allows users to enable thewasm_jsopt-in backend #574
Fixed
- NetBSD fallback code based on
KERN_ARND#555
-
0.3.0-rc.029 Nov 2024 pre-releaseNothing published for this version
-
0.2.1711 Jan 2026 -
0.2.1622 Apr 2025 -
0.2.1506 May 2024 -
0.2.1408 Apr 2024 -
0.2.1306 Apr 2024Release notes
Open source →Added
linux_disable_fallbackcrate feature to disable/dev/urandom-based fallback on Linux and Android targets. Enabling this feature bumps minimum supported Linux kernel version to 3.17 and Android API level to 23 (Marshmallow). #396
Changed
-
0.2.1209 Jan 2024Release notes
Open source →Fixed
- Custom backend for targets without atomics #385
Changed
- Improve robustness of the Hermit backend and
sys_fill_exact#386 - Raise minimum supported Apple OS versions to macOS 10.12 and iOS 10 #388
Added
- Document platform support policy #387
-
0.2.1108 Nov 2023 -
0.2.1006 Jun 2023Release notes
Open source →Added
- Support for PS Vita (
armv7-sony-vita-newlibeabihf) #359
Changed
- Use getentropy from libc on Emscripten targets #362
- Support for PS Vita (
-
0.2.906 Apr 2023Release notes
Open source →Added
- AIX support #282
getrandom_uninitfunction #291wasm64-unknown-unknownsupport #303- tvOS and watchOS support #317
- QNX/nto support #325
- Support for
getrandomsyscall on NetBSD ≥ 10.0 #331 RtlGenRandomfallback for non-UWP Windows #337
Breaking Changes
- Update MSRV to 1.36 #291
Fixed
- Solaris/OpenBSD/Dragonfly build #301
Changed
- Update MSRV to 1.36 #291
- Use getentropy on Emscripten #307
- Solaris: consistently use
/dev/randomsource #310 - Move 3ds selection above rdrand/js/custom fallback #312
- Remove buffer zeroing from Node.js implementation #315
- Use
openinstead ofopen64#326 - Remove #cfg from bsd_arandom.rs #332
- Hermit: use
sys_read_entropysyscall #333 - Eliminate potential panic in sys_fill_exact #334
- rdrand: Remove checking for 0 and !0 and instead check CPU family and do a self-test #335
- Move
__getrandom_customdefinition into a const block #344 - Switch the custom backend to Rust ABI #347
-
0.2.820 Oct 2022Release notes
Open source →Changed
- The Web Cryptography API will now be preferred on
wasm32-unknown-unknownwhen using the"js"feature, even on Node.js #284 #295
Added
- Added benchmarks to track buffer initialization cost #272
Fixed
- Use
$crateinregister_custom_getrandom!#270
Documentation
- The Web Cryptography API will now be preferred on
-
0.2.714 Jun 2022Release notes
Open source →Changed
- Update
wasidependency to0.11#253
Fixed
- Use
AtomicPtrinstead ofAtomicUsizefor Strict Provenance compatibility. #263
Documentation
- Update
-
0.2.628 Mar 2022Release notes
Open source → -
0.2.522 Feb 2022 -
0.2.413 Jan 2022 -
0.2.320 May 2021 -
0.2.219 Jan 2021 -
0.2.104 Jan 2021 -
0.2.010 Sep 2020Release notes
Open source →Features for using getrandom on unsupported targets
The following (off by default) Cargo features have been added:
"rdrand"- use the RDRAND instruction onno_stdx86/x86_64targets #133"js"- use JavaScript calls onwasm32-unknown-unknown#149- Replaces the
stdwebandwasm-bindgenfeatures (which are removed)
- Replaces the
"custom"- allows a user to specify a custom implementation #109
Breaking Changes
- Unsupported targets no longer compile #107
- Change/Add
Errorconstants #120 - Only impl
stdtraits when the"std"Cargo feature is specified #106 - Remove official support for Hermit, L4Re, and UEFI #133
- Remove optional
"log"dependency #131 - Update minimum supported Linux kernel to 2.6.32 #153
- Update MSRV to 1.34 #159
-
0.1.1631 Dec 2020Release notes
Open source →Changed
- Update
cfg-ifto v1.0. #173 - Implement
std::error::Errorfor theErrortype on additional targets. #169
Fixed
- Multithreaded WASM support. #171
- Update
-
0.1.1510 Sep 2020 -
0.1.1407 Jan 2020 -
0.1.1325 Oct 2019Release notes
Open source →Added
- VxWorks targets support. #86
Changed
- If zero-length slice is passed to the
getrandomfunction, always returnOk(())immediately without doing any calls to the underlying operating system. #104 - Use the
kern.arandomsysctl on NetBSD. #115
Fixed
-
0.1.1206 Sep 2019 -
0.1.1125 Aug 2019Release notes
Open source →Fixed
- Implement
std-dependent traits for selected targets even ifstdfeature is disabled. (backward compatibility with v0.1.8) #96
- Implement
-
0.1.1017 Aug 2019 withdrawnRelease notes
Open source →Changed
- Use the dummy implementation on
wasm32-unknown-unknowneven with the disableddummyfeature. #90
Fixed
- Fix CSP error for
wasm-bindgen. #92
- Use the dummy implementation on
-
0.1.914 Aug 2019 withdrawnRelease notes
Open source →Changed
- Remove
stddependency for opening and reading files. #58 - Use
wasiinstead oflibcon WASI target. #64 - By default emit a compile-time error when built for an unsupported target.
This behaviour can be disabled by using the
dummyfeature. #71
Added
- Remove
-
0.1.805 Aug 2019 -
0.1.729 Jul 2019Release notes
Open source →Added
- Support for hermit and l4re. #61
Error::raw_os_errormethod,Error::INTERNAL_STARTandError::CUSTOM_STARTconstants. Uselibcfor retrieving OS error descriptions. #54
Changed
- Remove
lazy_staticdependency and use custom structures for lock-free initialization. #51 #52 - Try
getrandom()first on FreeBSD. #57
Removed
- Bitrig support. #56
Deprecated
Error::UNKNOWN,Error::UNAVAILABLE. #54
-
0.1.630 Jun 2019 -
0.1.529 Jun 2019Release notes
Open source →Fixed
- Use shared
Fileinstead of shared file descriptor. #44 - Workaround for RDRAND hardware bug present on some AMD CPUs. #43
Changed
- Try
getentropyand then fallback to/dev/randomon macOS. #38
- Use shared
-
0.1.428 Jun 2019Release notes
Open source →Added
- Add support for
x86_64-unknown-uefitarget by using RDRAND with CPUID feature detection. #30
Fixed
- Fix long buffer issues on Windows and Linux. #31 #32
- Check
EPERMin addition toENOSYSon Linux. #37
Changed
- Add support for
-
0.1.317 May 2019Release notes
Open source →- Update for
wasm32-unknown-wasibeing renamed towasm32-wasi, and for WASI being categorized as an OS.
- Update for
-
0.1.206 Apr 2019 -
0.1.105 Apr 2019 -
0.1.023 Mar 2019 -
0.0.019 Jan 2019