implement random number generator

Signed-off-by: Mattias Andrée <maandree@operamail.com>
m doc

Signed-off-by: Mattias Andrée <maandree@operamail.com>
reorder methods

Signed-off-by: Mattias Andrée <maandree@operamail.com>