eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'RandomGenerator':

Home

everywhere
www.exept.de
for:
[back]

Class: RandomGenerator


Inheritance:

   Object
   |
   +--RandomGenerator

Package:
stx:libbasic2
Category:
Magnitude-Numbers
Version:
rev: 1.8 date: 2010/03/31 10:37:41
user: stefan
file: RandomGenerator.st directory: libbasic2
module: stx stc-classLibrary: libbasic2
Author:
Stefan Vogel

Description:


This is a Random number generator, which uses either a OS random number generator,
or a ST/X internal random number generator.



[instance variables:]

[class variables:]
    RandFile        the FileStream we get random numbers from


Related information:

    Random
    HashRandom
    Rc4Stream

Class protocol:

adding entropy
o  addEntropy: entropyBytes

change & update
o  update: something with: aParameter from: changedObject
handle image restarts and flush any device resource handles

initialization
o  initialize
want to be informed when returning from snapshot

o  openRandFile
try to open a random device

instance creation
o  new
return a new random number generator.
Try to get system random numbers from device (e.g. in LINUX).
If no system random nubers are available, fall back to
a cryptographic secure PRNG (part of the extra libcrypt package).
As last resort fallback to the cryptographic insecure linear builtin PRNG

o  random
alias for new - protocol compatibility with StreamCiphers

queries
o  randPath
path to a file/device that is a source or random numbers


Instance protocol:

adding entropy
o  addEntropy: entropyBytes
add some entropy - ignored here, since I am file based

basic reading
o  nextByte
get the next random byte

o  nextBytes: cnt
get the next cnt random bytes

o  nextInteger
return the next integral random number,
in the range 0 .. 16r3FFFFFFF.

reading
o  next
return the next random number in the range 0..1

o  nextBetween: start and: stop
return a random number between start and stop.

o  nextBoolean
return true or false by random

o  nextCharacters: cnt
get the next cnt printable characters.
We answer characters in the ascii range (codepoints 32 - 127)

o  nextIntegerBetween: start and: stop
return an integral random number between start and stop

o  nextMatchFor: aNumber
generate the next random, return true iff it has the same
value as aNumber. Redefined to avoid endless reading.

writing
o  nextPut: something
change the random pool by feeding in something.
Something should be some unpredictable, random event.
Ignored here

o  nextPutAll: something
change the random pool by feeding in something.
Something should be some unpredictable, random event.
Ignored here



ST/X 6.1.1; WebServer 1.620 at exept:8081; Tue, 22 May 2012 21:54:07 GMT