1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00
ladybird/Libraries/LibCrypto/SecureRandom.h
R-Goc d60543c2cb LibJS/LibCrypto: Cleanup JS Math random() RNG
This commit adds a convenience method to secure random for initializing
single types. It changes the random number generator in JS math random()
to use newer constants by the author as well as initializes it with a
higher quality seed.
2025-05-15 07:41:02 -06:00

23 lines
322 B
C++

/*
* Copyright (c) 2024, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Span.h>
namespace Crypto {
void fill_with_secure_random(Bytes);
template<typename T>
inline T get_secure_random()
{
T t;
fill_with_secure_random({ &t, sizeof(T) });
return t;
}
}