1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Add LuaSecureRandom

This commit is contained in:
est31 2015-08-06 08:57:13 +02:00 committed by kwolekr
parent d506d56707
commit ad5ac39d8d
6 changed files with 201 additions and 1 deletions

View file

@ -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_ */