protected function getNonce()
    {
        $nonce = '';

        // get 16 random bytes
        for ($i = 0; $i < 16; $i++) {
            $nonce .= chr(mt_rand(0, 255));
        }

        // base-64 encode them
        $nonce = base64_encode($nonce);

        return $nonce;
    }