r/lua • u/Savings_Part_234 • Apr 05 '26
How would you securely handle RNG for a server between TypeScript and a Lua client to prevent hooking on the client side?
I guess the title covers it
4
Upvotes
5
u/DapperCow15 Apr 05 '26
Title does not cover it for me. Why can't you handle the RNG calculations entirely on the server and validate client inputs? Like what's the context of this?
4
u/c__beck Apr 05 '26
From your other comments it sounds like you're looking for a nonce. But without more information it's hard to say.
What are you doing that you think requires cryptographically secure random number? What is it that you're trying to prevent? What data does your server have that you're trying to protect?
1
u/bloxmetrics Apr 05 '26
All RNG that affects gameplay needs to happen on the server. Generate your random values there, send the results to the client, not the seed or algorithm. Clients can't be trusted with anything that matters. I've seen people try to validate client-side RNG and it always gets bypassed. Just bite the bullet and do it server-side, the latency is usually fine for most games.