Roblox CDN, How do I know which one to use?

If you want to solve this problem without sending a request or looping through all CDNs, this trick works.

Here’s a little JavaScript code snippet that’ll do the job:

function get(hash) {
    for (var i = 31, t = 0; t < 32; t++)
        i ^= hash[t].charCodeAt(0);
    return `https://t${(i % 8).toString()}.rbxcdn.com/${hash}`;
}

and the same thing in Python:

def get(hash):
    i = 31
    for char in hash[:32]:
        i ^= ord(char)  # i ^= int(char, 16) also works
    return f"https://t{i%8}.rbxcdn.com/{hash}"

It creates a variable i with a value of 31, iterates through the first 32 characters of the string, and, on each iteration, sets i to itself Bitwise XORed against the integer representation of that character (or, alternatively, just the integer version of the hex value with int(char, 16) if you prefer it - as far as I can tell, it works in the same way)

Thanks to @juliaoverflow for helping me with the same problem three months ago.

10 Likes