Repos

MELHARFI-2D-Game-Engine.

Got to repo.

13. Cryptography

Encrypting assets

The idea is when you attempt to create a game, you probably want to keep your assets as pictures encrypted and not clearly visible so another person can modify them.

For that purpose i made a tool to encrypt and decrypt them so they will be not readable.

Here is the latest release of EncryptDecrypt tool Link

Here is the link of the repository if you want more details about the source code and How to : CryptDecrypt

  • How to use an encrypted asset in MELHARFI Engine
  • After that you just need to use the correct overload of the Bmp or Anim object and specify the 2 keys for encrypting like so :

                            
    using System;
    using System.Drawing;
    using System.Linq;
    using System.Windows.Forms;
    using MELHARFI.Manager;
    using MELHARFI.Manager.Gfx;
    
    namespace _2dProject
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
                Manager manager = new Manager(this, "manager");
                manager.Background = Color.CadetBlue;
    
                Bmp supermario = new Bmp(@"supermario_encrypted.png", new Point(100, 200), "supermario", Manager.TypeGfx.Object, true, "↔⊆b¤õΔ⑨É", "❿9<#§∴Q➚", manager);
                manager.ObjectLayer.Add(supermario);
            }
    
        }
    }
                            
                          

    The 2 keys "↔⊆b¤õΔ⑨É", "❿9<#§∴Q➚" are generated using the tool, and another image has been generated supermario_encrypted.png

    Encode64 / Decode64

    There is a built-in encryption using Base64 which is quite familiar but still usefull to give an easy encrypting layer especially when you want to encrypt the text sent by the network.

                            
    using System;
    using System.Drawing;
    using System.Linq;
    using System.Windows.Forms;
    using MELHARFI.Manager;
    using MELHARFI.Manager.Gfx;
    
    namespace _2dProject
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
    
                Manager manager = new Manager(this, "manager");
                manager.Background = Color.CadetBlue;
    
                string message = "Hello World";
                Crypt crypt = new Crypt();
                string encryptMessage = crypt.Encode64(message);
                // encryptMessage has the value = "SGVsbG8gV29ybGQ="
    
                string decryptedMessage = crypt.Decode64(encryptMessage);
                // decrypted value is "Hello World"
            }
        }
    }
                            
                          

    Services

    App Developpement

    Want me to dev an app for you ? dont hesitate to contact me.

    Programming

    Are you looking for a coder/teammate for your project ? Let's give it a try.

    Job Invitation

    Have a proposal for me ? we can discuss about it.

    Donation maybe ?!

    You want to buy me a coffe ? m.elharfi@gmail.com