0

I am trying to decode this Base64 string that is generated inside an online game, but I can not make any sense out of it. This is from an online game where you can have different outfits/styles in the game for your character. You can pick your colors, mounts, and what type of clothing to wear. You then have the option to save your entire outfit (look, colors, etc.) and it turns into a Base64 string, and also saves it as a JSON file locally on my computer. But what I am interested in is to read this Base64 string.

pGVtb3VudKJlY29sb3KkZmRldGFpbABkaGVhZABkbGVncwBldG9yc28AYmlkAGRuYW1lYGZvdXRmaXSkZWNvbG9ypGZkZXRhaWwYfGRoZWFkAGRsZWdzGHJldG9yc28YX2pmaXJzdEFkZE9u9GJpZBiBa3NlY29uZEFkZE9u9GZzdW1tb26hYmlkAA

The game I am playing then saves this as a JSON file. The above code gets converted into this, stored in a locally save file.

{
"mount": {
    "color": {
        "detail": 0,
        "head": 0,
        "legs": 0,
        "torso": 0
        },
    "id": 0
    },
        "name": "Example",
        "outfit": {"color": {
        "detail": 124,
        "head": 0,
        "legs": 114,
        "torso": 95
    },
        "firstAddOn": false,
        "id": 129,
        "secondAddOn": false
    },
    "summon": {
    "id": 0
}

}

But I am trying to decode the actual Base64 string and get its values out from there. All I get is this:

emountecolorfdetail�dhead�dlegs�etorso�bid�dname`foutfitecolorfdetail|dhead�dlegsretorso_jfirstAddOnbidksecondAddOnfsummonbid�

At least I can see some values.

mount: e
color: f
detail: �d
head: �d
legs: �e
torso: �b

and so on...

But looking at the file saved, the values should be numbers. That is what I am trying to get. The values from the variables.

  • I can't fully answer this, but at least some hints: decode the base64 code to hex (e.g. `console.log(Buffer.from(b64, "base64").toString("hex"))` in node.js) then you can see the real byte values instead of some odd characters. For example, there's a sequence "64 65 74 61 69 6c 18 7c 64", which is "d e t a i l | d", basically ASCII codes, but `7c`, printed as '|' is the value 124. – jps Jul 22 '21 at 09:35
  • It seems like they use some kind of binary JSON encoding rather than the original JSON format. There are multiple options for that out there, [BSON](https://en.wikipedia.org/wiki/BSON) is one example. – Joachim Sauer Jul 22 '21 at 10:20

1 Answers1

0

There seems to be some issue with your encoded string(might have ASCII/Unicode characters), but generally, atob can used to decode a Base64 string. You can try the other way around too, try converting your JSON to string with JSON.stringify() and encode with btoa

Refer the first ans here - Using Javascript's atob to decode base64 doesn't properly decode utf-8 strings