Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3358280
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:44:01+00:00 2026-05-18T02:44:01+00:00

I am running a website, and there is a scoring system that gives you

  • 0

I am running a website, and there is a scoring system that gives you points for the number of times you play a game.

It uses hashing to prove the integrity of http request for scoring so users cannot change anything, however as I feared might happen, someone figured out that they didn’t need to change it, they just needed to get a high score, and duplicate the http request, headers and all.

Previously I’d been prohibited from protecting against this attack because it was considered unlikely. However, now that it has happened, I can. The http request originates from a flash game, and then is validated by php and php enters it into the database.

I’m pretty sure nonces will solve the issue, but I’m not exactly sure how to implement them. What is a common, and secure way of setting up a nonce system?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T02:44:01+00:00Added an answer on May 18, 2026 at 2:44 am

    It’s actually quite easy to do… There are some libraries out there to do it for you:

    1. PHP Nonce Library
    2. OpenID Nonce Library

    Or if you want to write your own, it’s pretty simple. Using the WikiPedia page as a jumping off point, In pseudo-code:

    On the server side, you need two client callable functions

    getNonce() {
        $id = Identify Request //(either by username, session, or something)
        $nonce = hash('sha512', makeRandomString());
        storeNonce($id, $nonce);
        return $nonce to client;
    }
    
    verifyNonce($data, $cnonce, $hash) {
        $id = Identify Request
        $nonce = getNonce($id);  // Fetch the nonce from the last request
        removeNonce($id, $nonce); //Remove the nonce from being used again!
        $testHash = hash('sha512',$nonce . $cnonce . $data);
        return $testHash == $hash;
    }
    

    And on the client side:

    sendData($data) {
        $nonce = getNonceFromServer();
        $cnonce = hash('sha512', makeRandomString());
        $hash = hash('sha512', $nonce . $cnonce . $data);
        $args = array('data' => $data, 'cnonce' => $cnonce, 'hash' => $hash);
        sendDataToClient($args);
    }
    

    The function makeRandomString really just needs to return a random number or string. The better the randomness, the better the security… Also note that since it’s fed right into a hash function, the implementation details don’t matter from request to request. The client’s version and the server’s version don’t need to match. In fact, the only bit that needs to match 100% is the hash function used in hash('sha512', $nonce . $cnonce . $data);… Here’s an example of a reasonably secure makeRandomString function…

    function makeRandomString($bits = 256) {
        $bytes = ceil($bits / 8);
        $return = '';
        for ($i = 0; $i < $bytes; $i++) {
            $return .= chr(mt_rand(0, 255));
        }
        return $return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an asp.net website that uses forms authentication. There are a few things
I've got a website running on Amazon Web Services that is deployed using Elastic
I have an existing website running on IIS6 that has only static HTML pages.
We got a long-running website where XSS lurks. The problem comes from that some
Any idea, how can we create already running website to Mobile Website? Are there,
I'm running a website with 3 domains redirecting to that domain (without a index
I have a shopping cart website running classic ASP that needs help during the
I have a production website running apache on linux. There are all sorts of
I have a website running a basic ASP.NET application that is mostly used from
Say you have a legacy website running on an old code-base that offers certain

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.