Skip to content

Instantly share code, notes, and snippets.

@perryqh
Created November 13, 2009 00:43
Show Gist options
  • Save perryqh/233465 to your computer and use it in GitHub Desktop.
Save perryqh/233465 to your computer and use it in GitHub Desktop.
# = srand_seed_generator.rb - Random seed generator uses the system time and currently running processes to generate a highly random seed.
#
# Perry Hertler mailto:[email protected]
#
# == Example
#
# my_seed = PwFoo::SrandSeedGenerator.new.get_next_seed
module PwFoo
require 'digest/md5'
class SrandSeedGenerator
def initialize
end
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
def _get_checksum
Digest::MD5.hexdigest(`ps axww | gzip`)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment