Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion source/secured/random.d
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,17 @@ extern(C) @nogc nothrow private @system
else version(Windows)
{
import core.sys.windows.windows;
import core.sys.windows.wincrypt;
import std.format;

HCRYPTPROV hCryptProv;

//Get the cryptographic context from Windows
if (!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_VERIFYCONTEXT)) {
throw new CryptographicException("Unable to acquire Cryptographic Context.");
}
//Release the context when finished
scope(exit) CryptReleaseContext(hCryptoProv, 0);
scope(exit) CryptReleaseContext(hCryptProv, 0);

//Generate the random bytes
if (!CryptGenRandom(hCryptProv, cast(DWORD)buffer.length, buffer.ptr)) {
Expand Down