Decryption is nothing more than to modify the game function data, extract game resources, add the ads you want to add ...
Encryption is to protect the game is not malicious modification, often see someone say: "Add what secret, you think you write code very NB?" Dirty? "
I just want to say that encryption is not to let others see my game logic code, but do not want others to maliciously modify their own game just ...
First of all, about the Unity C # code part of the encryption (Android and iOS have time to elaborate), many people say confusion, although there are a few confusing plugins codeguard, Cryptoobfuscator, De4dot ... can use, but there is confusion there is anti-confusion (de4dot basic can be done), there is shell shelling, there is encryption there is decryption ... Encryption only raises the hurdle and increases the difficulty, and decryption is only the length of time.
There is not a lot of protection for C # in Unity, the Packers don't think about it, there are limits to confusion, mixed and not mixed.
In addition to confusion, we can also try other protections, such as the following:
Unity is based on mono, and everyone on earth knows ... It is open source code download: Https://github.com/Unity-Technologies/mono
Directly under Zip package (Note that the tag version is the same as the unity version used for development)
Compile your own Unity project, find/data/managed/assembly-csharp.dll, encrypt it, write a small program yourself, convert Assembly-csharp.dll to byte stream byte[], and encrypt byte[].
Here are some common cryptographic (validation) algorithms:
* Hash: MD5, SHA, SHA3, Ripemd, Tiger, Whirlpool, CRC32, Adler32
* Symmetry: Base64, DES, 3DES, AES, RC, Rijndael, TripleDES, PBE, 3-way, Idea, MARS, Serpent, SAFER, Blowfish, Twofish, Tea, Skipjack, Camellia, Cast, Gost
* Asymmetric: RSA, Elgamal, Diffie-hellman, Rabin, ECDsa, ECC
If you do not understand the above algorithm can see the following two open source Encryption class library (Google degrees Niang can also)
Bouncy Castle (C # and Java edition) code download: https://github.com/bcgit/website address: http://www.bouncycastle.org
crypto++ (c + +) code Download: http://sourceforge.net/projects/cryptopp/files/cryptopp/website address: http://www.cryptopp.com/
Some people say that. NET comes with a Security class library, indeed there are some commonly used algorithms under System.Security.Cryptography, although not all of the above class library, but enough for normal use.
Its C # source code is also in the Mono open source project location in/mcs/class/corlib/system.security.cryptography/if you do not want to know the encryption algorithm can be slightly, directly reference the method inside.
If you have Bambo, you can write a cryptographic algorithm that belongs to you ...
Here filter the hook or disassembly debugging mono loading Assembly-csharp.dll part ...
And then find/MONO/METADATA/IMAGE.C. See the two methods below
[Code]csharpcode:
Monoimage *
Mono_image_open_from_data_full (char *data, Guint32 Data_len, Gboolean need_copy, Monoimageopenstatus *status, Gboolean REFONLY)
{
return Mono_image_open_from_data_with_name (data, Data_len, need_copy, status, Refonly, NULL);
}
Monoimage *
Mono_image_open_from_data_with_name (char *data, Guint32 Data_len, Gboolean need_copy, Monoimageopenstatus *status, Gboolean refonly, const char *name)
{
Monocliimageinfo *iinfo;
Monoimage *image;
Char *datac;
if (!data | |!data_len) {
if (status)
*status = Mono_image_image_invalid;
return NULL;
}
DATAC = data;
if (need_copy) {
Datac = G_try_malloc (Data_len);
if (!DATAC) {
if (status)
*status = Mono_image_error_errno;
return NULL;
}
memcpy (DATAC, data, Data_len);
}
Image = G_new0 (monoimage, 1);
Image->raw_data = Datac;
Image->raw_data_len = Data_len;
image->raw_data_allocated = need_copy;
Image->name = (name = = NULL)? g_strdup_printf ("data-%p", Datac): G_strdup (name);
Iinfo = G_new0 (monocliimageinfo, 1);
Image->image_info = Iinfo;
Image->ref_only = refonly;
Image->ref_count = 1;
Image = Do_mono_image_load (image, status, true, true);
if (image = = NULL)
return NULL;
return register_image (image);
}
The first method in Mono_image_open_from_data_full actually calls the Mono_image_open_from_data_with_name
The second method mono_image_open_from_data_with_name the first argument of Char *data, which points to the memory address of the runtime Assembly-csharp.dll.
You can add or invoke the algorithm for data decryption within the method, and then assign the decrypted data to the DATAC
On the structure of monoimage, it is defined as typedef struct _MONOIMAGE monoimage; and _monoimage This structure, it's defined in/mono/metadata/metadata-internals.h.
The last is to compile mono, compile the part I will not say to see the official note
Although the method is to modify the mono kernel, the bottom of some, but it is not cracked, but rather than the difficulty of anti-confusion so a lost.
Unity Encryption Decryption