ntropy 0.1.1
Generate cryptographically secure pseudorandom data, compatible with BetterC, @safe, @nogc, and nothrow.
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
NTropy
This library provides a lightweight platform-independent interface to generate cryptographically secure pseudorandom data from system sources.
NTropy is compatible with @safe
, @nogc
and nothrow
, and can be compiled with BetterC compatibility.
Public methods in the source code have embedded documentation.
Usage
Fill a buffer with cryptographically secure random data:
import ntropy;
auto myBuffer = new ubyte[](32);
if(ntropy.generate(myBuffer)){
//use myBuffer
}else{
//error detected!
}
Supported platforms
System version identifier(s) | Minimum system version | Implementation |
---|---|---|
linux /Android | Kernel 3.17, glibc 2.25 | getrandom |
OSX | 10.10 | CCRandomGenerateBytes |
iOS | 8.0 | CCRandomGenerateBytes |
TVOS /WatchOS /VisionOS | (none) | CCRandomGenerateBytes |
Windows | Vista / Server 2008 | BCryptGenRandom |
FreeBSD | 12.0 | getrandom |
OpenBSD | 2.1 | arc4random_buf |
NetBSD | 10.0 | getrandom |
DragonFlyBSD | 5.7 | getrandom |
Hurd | (unknown) | getrandom |
Solaris | (unknown) | getrandom |
AIX | (unknown) | /dev/urandom |
Haiku | (unknown) | /dev/urandom |
Not all platforms have been tested. Pull requests to add new platforms, lower minimum system versions, or fix bugs are welcome.
BetterC compatibility
If you are using dub, then by default the library will compile without BetterC. To enable BetterC compatibility, select the yesBC
configuration in your dub recipe.
See also
- 0.1.1 released 34 days ago
- ichordev/NTropy
- BSL-1.0
- Authors:
- Dependencies:
- none
- Versions:
-
0.1.2 2025-Jan-01 0.1.1 2025-Jan-01 0.1.0 2025-Jan-01 ~trunk 2025-Jan-01 - Download Stats:
-
-
0 downloads today
-
4 downloads this week
-
5 downloads this month
-
6 downloads total
-
- Score:
- 0.4
- Short URL:
- ntropy.dub.pm