public function getRandomBytesString($byteCount){
        $chars = '';
        // try mcrypt
        if ($this->mcrypt) {
            $chars = mcrypt_create_iv($byteCount, MCRYPT_DEV_URANDOM);
        }
        // if it fails, use openssl_random_pseudo_bytes
        if (!$chars && $this->openssl) {
            $chars = openssl_random_pseudo_bytes($byteCount);
        }
        // if it fails, try /dev/urandom (will work only on unix based systems)
        if (!$chars && $this->urandom) {
            while (($len  = strlen($chars))< $byteCount) {
                $chars .= fread($this->urandomFileHandler, $byteCount - $len);
            }
        }
        // if it fails, throw an Exception
        if ($len = strlen($chars) < $byteCount) {
            throw new Exception('Cannot use a cryptographically secure PRNG.');
        }
        return $chars;
    }