pike.git / lib / modules / Crypto / randomness.pmod

version» Context lines:

pike.git/lib/modules/Crypto/randomness.pmod:1: - /* $Id: randomness.pmod,v 1.15 2000/03/28 12:24:32 grubba Exp $ + /* $Id: randomness.pmod,v 1.16 2000/04/15 09:34:26 hubbe Exp $    */      //! module Crypto   //! submodule randomness   //! Assorted stronger or weaker randomnumber generators.      /* These devices tries to collect entropy from the environment.    * They differ in behaviour when they run low on entropy, /dev/random    * will block if it can't provide enough random bits, while /dev/urandom    * will degenerate into a reasonably strong pseudo random generator */
pike.git/lib/modules/Crypto/randomness.pmod:87:   }         //! class pike_random   //! A pseudo random generator based on the ordinary random() function.   class pike_random {    //! method string read(int len)    //! Returns a string of length len with pseudo random values.    string read(int len)    { + #if 1 // major optimization /Hubbe +  return random_string(len); + #else   #if 1 // 30% optimization /Hubbe    string ret="";    if(len>=16384)    {    array x=allocate(16384,random);    for(int e=0;e<(len/16384);e++) ret+=(string)x(256);    }    ret+=(string)allocate(len % 16384, random)(256);    return ret;   #else    if (len > 16384) return read(len/2)+read(len-len/2);    return (string)allocate(len, random)(256);   #endif -  + #endif    }   }      #if constant(Crypto.arcfour)   //! class arcfour_random   //! A pseudo random generator based on the arcfour crypto.   class arcfour_random {    inherit Crypto.arcfour : arcfour;       //! method void create(string secret)