Class: PwFoo::SrandSeedGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/pwfoo/srand_seed_generator.rb

Instance Method Summary collapse

Constructor Details

#initializeSrandSeedGenerator

Returns a new instance of SrandSeedGenerator.



5
6
# File 'lib/pwfoo/srand_seed_generator.rb', line 5

def initialize
end

Instance Method Details

#_get_checksumObject



15
16
17
# File 'lib/pwfoo/srand_seed_generator.rb', line 15

def _get_checksum
  Digest::MD5.hexdigest(`ps axww | gzip`)
end

#get_next_seedObject



8
9
10
11
12
13
# File 'lib/pwfoo/srand_seed_generator.rb', line 8

def get_next_seed
  time_in_micro = Time.new().to_f * 100000
  checksum = _get_checksum

  time_in_micro * time_in_micro + checksum.to_i
end