mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-14 09:05:19 +02:00
Add LuaSecureRandom
This commit is contained in:
@@ -160,4 +160,37 @@ public:
|
||||
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];
|
||||
|
||||
// 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_ */
|
||||
|
Reference in New Issue
Block a user