home bbs files messages ]

Forums before death by AOL, social media and spammers... "We can't have nice things"

   comp.lang.c      Meh, in C you gotta define EVERYTHING      243,242 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 242,601 of 243,242   
   BGB to All   
   Re: srand(0)   
   25 Dec 25 03:07:03   
   
   From: cr88192@gmail.com   
      
   On 12/24/2025 1:00 PM, Lawrence D’Oliveiro wrote:   
   > On Wed, 24 Dec 2025 15:21:11 -0000 (UTC), Michael Sanders wrote:   
   >   
   >> On Wed, 24 Dec 2025 06:16:51 -0000 (UTC), Lawrence D’Oliveiro wrote:   
   >>   
   >>>> Wish there was such a 'device' under Windows...   
   >>>   
   >>> You should get one if you install WSL2.   
   >>   
   >> To be fair there is the 'Windows entropy pool' & its   
   >> non-deterministic too but its only available via API.   
   >   
   > You begin to see why Microsoft is supporting Linux more and more.   
      
      
   Usual strategy IME is usually to save a file or similar with RNG state   
   for a big RNG hidden inside somewhere, and then the program loads the   
   file, goes through an "entropy mining" step, and then either immediately   
   or eventually saves the file again.   
      
   This approach is generally portable.   
      
      
   In some other types of programs, the RNG state is hidden inside some   
   other type of data that tends to be saved and reloaded (such as the   
   player state in a 3D engine).   
      
   One entropy-mining process is to use "clock()" or similar and then spin   
   in a loop for a certain amount of time effectively building a hash of   
   the values returned by clock. The exact timing when the values change   
   will tend to carry a certain amount of entropy.   
      
      
   Say, for example:   
      t0=clock();   
      t0e=t0+(0.1*CLOCKS_PER_SEC);  //usually not too obnoxious.   
      t1=t0;   
      seed1=1; seed2=1;   
      while(t1>32);   
      seed2+=((uint32_t)seed2)+(seed2>>32);   
      seed=seed1^seed2;   
      
   This can be combined with the saved/restored RNG state.   
      
   This entropy-mining approach seems to work reasonably well despite its   
   limitations (will typically give a unique value each run).   
      
   granted, doesn't work if the system as a whole is sufficiently   
   deterministic (doesn't really work on microcontrollers or similar).   
      
   ...   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]


(c) 1994,  bbs@darkrealms.ca