Facepunch / garrysmod-requests

Feature requests for Garry's Mod
83 stars 24 forks source link

idea: math.SecureRandom(bytes?) #2413

Open JustPlayerDE opened 2 weeks ago

JustPlayerDE commented 2 weeks ago

A method to get cryptographically secure random values from /dev/urandom on unix based systems (linux or mac) and CNG/CryptGenRandom on windows could be useful.

This is not a must-have but would still be nice. This would also add a way to get secure random values even if some addon plays with the math.random seed.

It should ideally just return byte? (at least 1) amount of raw bytes returned by the os, converting that to a number should be easy enough if required by the user.

Just in case its important: it should not cause any privacy or security issues returning raw output from urandom or similar os features, these should be fully random no matter the configuration of the system

ryanoutcome20 commented 2 days ago

You can have cryptographically secure random seeds by using the offset address of functions as long as it's done on separate realms.

local Example = tostring( function() end ) 
MsgN( Example:sub( 13, #Example ):byte( 1, #Example ) ) -- output: 565110297529710197