Added GetRandomBytes (#10)

This commit is contained in:
Adubbz 2019-05-10 22:36:18 +10:00 committed by SciresM
parent 8ec43f0d69
commit 8f2328975a
2 changed files with 5 additions and 0 deletions

View File

@ -21,6 +21,7 @@ class StratosphereRandomUtils {
public:
static u32 GetRandomU32(u32 max);
static u64 GetRandomU64(u64 max);
static void GetRandomBytes(void* out, size_t size);
template<typename T>
static T GetRandom(T max);

View File

@ -82,3 +82,7 @@ u64 StratosphereRandomUtils::GetRandomU64(u64 max) {
return GetRandom<u64>(max);
}
void StratosphereRandomUtils::GetRandomBytes(void* out, size_t size) {
std::generate(reinterpret_cast<u8*>(out), reinterpret_cast<u8*>(out) + size, std::bind(GetRandom<u8>, 0xFF));
}