Response token

Prove the answer came from ModKey and belongs to this exact request.

The success answer carries a token; rebuild it on the client from the values you sent and compare.

Keep in mind

Lowercase hex
Every algorithm answers a lowercase hex digest.
The secret stays home
Set it in Connect Settings > Request > Secret. It is never a request field.
Default source
New software signs {{game}}-{{key}}-{{serial}}-{{secret}} with md5.
Test endpoint
Test Connect always signs with hmac-sha256 and a separate prefix, see test endpoint.

Algorithms

Algorithm Token
md5 hex(MD5(source))
sha256 hex(SHA256(source))
sha512 hex(SHA512(source))
hmac-sha256 hex(HMAC-SHA256(source, CONNECT_SECRET))

Building the source

The source is a template you choose in Connect Settings. These placeholders are filled with the values of the request:

Placeholder Value
{{game}} Game sent in the request
{{key}} License key sent in the request
{{serial}} Device id sent in the request
{{secret}} Your Connect secret, never sent over the wire
{{soft_id}} Software id
Default source and an example
{{game}}-{{key}}-{{serial}}-{{secret}}
pubg-XXXX-XXXX-XXXX-XXXX-device-id-<CONNECT_SECRET>

Verifying

  1. Read the token from the response.
  2. Build source_template from the same values sent in the request.
  3. Calculate the selected hash.
  4. Compare both values in constant time.

The samples below use the recommended hmac-sha256 with the source {{soft_id}}|{{game}}|{{key}}|{{serial}}.

$source = "{$soft}|{$game}|{$key}|{$serial}";
$expected = hash_hmac('sha256', $source, CONNECT_SECRET);

if (! hash_equals($expected, $answer['data']['token'])) {
    throw new RuntimeException('Bad token');
}

Keep {{secret}} out of the source

This signature source includes CONNECT_SECRET, and the success response returns the source in real. To keep the secret private, use hmac-sha256 with a source without {{secret}}. For example {{soft_id}}|{{game}}|{{key}}|{{serial}}.

Esc