Created
September 12, 2023 22:30
-
-
Save Osb0rn3/625510b5fe829ac5c85ca2a8f72948ba to your computer and use it in GitHub Desktop.
JavaScript code for generating checksum for Gamee
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Include the crypto-js library dynamically | |
var script = document.createElement('script'); | |
script.src = 'https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.9-1/crypto-js.js'; | |
script.onload = function () { | |
// The script has loaded, now you can use CryptoJS | |
function extractGameId() { | |
// Replace this with your actual logic to extract the game ID from the DOM | |
const iframe = document.querySelector('iframe[src*="game-"]'); | |
if (iframe) { | |
const src = iframe.getAttribute('src'); | |
const regexPattern = /game-(\d+)/; | |
const match = src.match(regexPattern); | |
if (match) { | |
return match[1]; // Extracted game ID | |
} | |
} | |
return null; // Return null if not found | |
} | |
function extractGameUrl() { | |
// Replace this with your actual logic to extract the game URL from the DOM | |
const metaElement = document.querySelector('meta[property="og:url"]'); | |
if (metaElement) { | |
const content = metaElement.getAttribute('content'); | |
const regexPattern = /\/game-bot\/[\w-]+/; | |
const match = content.match(regexPattern); | |
if (match) { | |
return match[0]; // Extracted game URL | |
} | |
} | |
return null; // Return null if not found | |
} | |
function generate_md5_checksum(score, playTime = 900, state = "") { | |
const gameId = extractGameId(); | |
const gameUrl = extractGameUrl(); | |
console.log({ gameId, gameUrl }) | |
if (gameId && gameUrl) { | |
const checksumString = `${score}:${playTime}:${gameUrl}:${state}:crmjbjm3lczhlgnek9uaxz2l9svlfjw14npauhen`; | |
// Calculate the MD5 hash using crypto-js | |
const md5Checksum = CryptoJS.MD5(checksumString).toString(); | |
return md5Checksum; | |
} | |
return "Unable to generate checksum"; | |
} | |
// Example usage: | |
const checksum = generate_md5_checksum(150190, 9034); | |
console.log(checksum); | |
}; | |
document.head.appendChild(script); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
can you please update it, the checksum is not matching with the gamee checksum