Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2765,6 +2765,15 @@ It can be created via `PcgRandom(seed)` or `PcgRandom(seed, sequence)`. | |
* This is only a rough approximation of a normal distribution with mean=(max-min)/2 and variance=1 | ||
* Increasing num_trials improves accuracy of the approximation | ||
|
||
### `SecureRandom` | ||
Interface for the operating system's crypto-secure PRNG. | ||
|
||
It can be created via `SecureRandom()`. The constructor returns nil if a secure random device cannot be | ||
be found on the system. | ||
|
||
#### Methods | ||
* `next_bytes([count])`: return next `count` (default 1, capped at 2048) many random bytes, as a string. | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
est31
Author
Contributor
|
||
|
||
### `PerlinNoise` | ||
A perlin noise generator. | ||
It can be created via `PerlinNoise(seed, octaves, persistence, scale)` | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,4 +160,37 @@ class LuaPcgRandom : public ModApiBase { | |
static void Register(lua_State *L); | ||
}; | ||
|
||
|
||
/* | ||
LuaSecureRandom | ||
*/ | ||
class LuaSecureRandom : public ModApiBase { | ||
private: | ||
static const size_t RAND_BUF_SIZE = 2048; | ||
static const char className[]; | ||
static const luaL_reg methods[]; | ||
|
||
u32 m_rand_idx; | ||
char m_rand_buf[RAND_BUF_SIZE]; | ||
This comment has been minimized.
Sorry, something went wrong.
ShadowNinja
Member
|
||
|
||
// Exported functions | ||
|
||
// garbage collector | ||
static int gc_object(lua_State *L); | ||
|
||
// next_bytes(self, count) -> get count many bytes | ||
static int l_next_bytes(lua_State *L); | ||
|
||
public: | ||
bool fillRandBuf(); | ||
|
||
// LuaSecureRandom() | ||
// Creates an LuaSecureRandom and leaves it on top of stack | ||
static int create_object(lua_State *L); | ||
|
||
static LuaSecureRandom *checkobject(lua_State *L, int narg); | ||
|
||
static void Register(lua_State *L); | ||
}; | ||
|
||
#endif /* L_NOISE_H_ */ |
Why the low upper limit?