Ways to encrypt/serialize my game data

Hi

So I am currently working on a level editor for my game and I of course need to be able to save the levels my players make. So I first used BinaryFormatter and that worked very good until I got to the part of sharing it. The web server that the levels will be uploaded to can only accept strings. This did not work very well with my BinaryFormatter setup. So I think I need to find a new way but I don’t know any encryption/serialization methods. I need a method so the player can’t edit the level outside the game (like editing parameters in notepad) basically. But I also need to be able to get it as a string that easily can be uploaded to a server. And then when I fetch it I would still be able to get parameters out of it. The web server I am using returns the saved elements as “keys” these keys return two parameters. The name and the data. I need to get the data on the fetch as I need to set the name, author, info e.t.c in the UI.

Now the class I need to save to a file is the following:

[System.Serializable]
class LevelData
{
    public string levelName;
    public string levelAuthor;
    public string date;
    public float time;
    public bool exported;

    public List<ObjectData> objectData = new List<ObjectData>();

}

And that then contains the object data class which looks like this:

[System.Serializable]
public class ObjectData
{
    public int objectID;
    public float xPos, yPos, zPos, xRot, yRot, zRot, xScale, yScale, zScale, cannonFireRate, cannonRadius;
    public string cubeName;

    public ObjectData(int newObjectID, float newXPos, float newYPos, float newZPos, float newXRot, float newYRot, float newZRot, float newXScale, float newYScale, float newZScale, string newCubeName, float newCannonRadius, float newCannonFireRate)
    {
        objectID = newObjectID;
        xPos = newXPos;
        yPos = newYPos;
        zPos = newZPos;
        xRot = newXRot;
        yRot = newYRot;
        zRot = newZRot;
        xScale = newXScale;
        yScale = newYScale;
        zScale = newZScale;
        cubeName = newCubeName;
        cannonFireRate = newCannonFireRate;
        cannonRadius = newCannonRadius;
    }
}

So any help is appreciated! I am not the best at explaining things so if you need more info to be able to help then ask for more info. I’ll try my best!

Thanks in advance!

I see two options:

  1. convert your binary format to a string. A Char in C# is 16 bit so you can either convert every byte in your byte array to a char or if you want half of the file size you could combine pairs of bytes and convert that to a char.

  2. use any ascii file format (Json, Yaml, XML, …) and save your data with that. To prevent the player of making illegal levels you could either evaluate the data on the server or saving a checksum (SHA or something) within the file.
    The latter option is relatively simple but not 100% safe because with inverse engineering hackers could find out how to generate such a check sum. But

is it really that important that players cannot edit the level data with a text editor?