<?php $sequence = new Sequence("foobar"); for ($i = 0; $i < 10; $i++) { echo $sequence->int64() . ' '; } class Sequence { protected $seed; public function __construct($seed) { $this->seed = $seed; $this->mix(); } public function int32() { $parts = unpack('l', $this->mix()); return $parts[1]; } public function int64() { $parts = unpack('i', $this->mix()); return $parts[1]; } public function float() { $parts = unpack('d', $this->mix()); return $parts[1]; } private function mix() { $hash = hash('sha512', $this->seed, true); $this->seed = substr($hash, 0, 32); return substr($hash, 32); } }
You have javascript disabled. You will not be able to edit any code.