- MD5 – Can I use MD5 as a two-way function? If I can break the data in 64 bit portions, will I be able to recover the original message without a pre-calculated lookup table?
MD5 is a hash function, not a cipher. Differently stated: you will not be able to encrypt or decrypt anything by simply using a hash function.
You could compare MD5 hashes with each other, but that would need you to “pre-calculate” hashes to which you would then compare those other hashes. But hashes will prevent you from learning about the original message (hashes are made to prevent that – among other things). Same goes for recovering the originally hashed data: you can’t. The reason is simple… a hash is not a compression tool which enables you to decompress contained data later on. There’s simply not enough information contained in a hash to do that (if recovering the original file from a hash were possible, everyone would be sharing short MD5 messages and things like torrents would have never been invented).
So – No, you can not use MD5 to recover the original message.
- Base64 – that can be easily used in both ways which is good cause it is easy, but this is also easy for hackers and crackers.
Base64 is nothing but a simple encoding method. A way to represent data. It has nothing to do with cryptography in the sense that it would be able to provide any kind of security. It is neither a hash, nor a cipher. All Base64 does is that it enables you to represent and transmit (mostly binary) data in a human-readable way. For example: Base64 comes handy when I would want to send you a binary file like an executable via email, but can not (or don’t want to) use the option to attach that file. With Base64, I could simply copy-and-paste the data as a message… which you would then need to convert back to binary data after receiving it.
Long story short – You can not (and should not) expect Base64 to provide any kind of security.
I don’t know how SHA and other kind of checksums and integrity checks work, or if they are aproperiate for this kind of data (numbers).
SHA is also a hash, just like MD5. Hash functions are fundamentally different from checksums like CRC32. Checksums are mainly build and used to verify the integrity of data (for example: during data-transmission, or after data storage), while cryptographic hash functions also target things that go well beyond data integrity checks. You could use a hash to provide what a checksum does, but a checksum can not provide all the things a hash can provide… things like “collision resistance” for example. In that sense, you could say hashes are “smarter” (but also slower to calculate).
To give you a hint related to all of your questions: What you are actually looking for is called a ”cipher”… an ”encryption algorithm”.
Some humble advice
Now, please don’t get me wrong… but you should really start from scratch with your research, since you are obviously getting most of the things you have been digging up absolutely wrong and trying to implement cryptography in your software with your current knowledge level is bound to fail.
To help you understand the fundamental things you are currently mixing up, I would humbly advise you to start reading the following two:
After reading (and understanding) those Wikipedia articles, slowly work your way up to the point where you can be confident that you know what you are doing and talking about.
On your way, things like the Handbook of Applied Cryptography (available for free as online version) will definitely come handy as it is easy to read once you grasped some minimal basics of crypto.
As said, please don’t get me wrong and please don’t take my advice as some kind of personal offense. I just do not want to see you fail securing your software or maybe even messing up the security of your game server, just because no one pointed you to the fact that you are currently simply too misinformed to even think about implementing cryptography in your game all by yourself.
On the positive side: you were smart enough to ask before doing something wrong, which is good. Therefore, I am confident that – with a bit time and effort – you’ll quickly reach a point where you’ll look back on this question and smile. Yet, think in weeks… not days or hours. Crypto can’t be learned in a day. In contrast, cryptography can be so tricky to implement that even experts sometimes fail to do it correctly because they missed a tiny detail somewhere. Gaining a somewhat useable level of knowledge so that you can implement it in your game and server surely won’t happen by tomorrow.
Adding part of the comments that followed up this answer:
… May you please advise me on finding an easy encrypt/decrypt with acceptable level of security? I prefer the method is common enough so I can use built in libraries while implementing both on server and client sides
Depends on the coding languages you’re using, but AES is available on about every platform and there are many libraries (eg: OpenSSL) out there supporting it. So, that could be an option… especially because you probably have the best chances finding "HowTo" tutorials related to it. Besides that, you’ll have to consider thinks like "keys" and “key exchange” (for authentication and encryption) but all that is too broad to wrap it up in a single answer or comment. If I were you, I would take things step-by-step and when in doubt – ask here or (if it’s source-related) at StackOverflow.
… I am a bit familiar with keys and two way keys concept and I think I can use AES by reading some tutorials …
That should wrap it up completely.