mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-08 05:27:14 +09:00

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.
23 lines
322 B
C++
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;
|
|
}
|
|
|
|
}
|