Advertisement

good encrypting algorithm for message

Started by July 19, 2004 08:19 AM
16 comments, last by FireNet 20 years, 6 months ago
What's good encrypting algorithm for message?
PGP relies upon public-private key encryption which is useful in messaging. However, you'll need to ensure that the client and server have both public and private keys, making it quite a hassle for game related messages.

I wrote a web-based system that used RC4 algorithms, the encryption on that was fairly good too and probably a little less hassle than public/private key encryption. You could also look into hashing (such as MD5), if you're aiming to verify login information (eg: username is sent hashed to the server which verifies with a hash of the server-stored username).
Advertisement
In fact,what I want to know is algorithm which is for free and has a key.
If you want a simple solution you can stick in your code easily, try TEA (Tiny Encryption Algorithm)
What about blowfish? It's quite fast and nice, but it's symmetric (not like PGP).
I know that HawkVoice (http://www.hawksoft.com/cgi/clickcount.pl?action=jump&URL=HawkVoiceDI091src.zip) includes source code for a blowfish implementation.

Regarding information about various cipher algorithms, you could try looking up wikipedia.org -- there's quite a lot of general information on that topic.
-- Rasmus Neckelmann
I like both TEA and Blowfish for small cryptos that are free, and uses symmetric keys. Blowfish has withstood significant scrutiny and not been weakened yet; TEA is a little younger but brilliantly simple. Either would be fine for game messages, as long as you can determine that there's no loss -- they're stream cryptos.

There are various ways to turn stream cryptos into message cryptos, such as pre-generating some set of keys, and picking one per message (based on sequence number, say). When the sequence number wraps, you re-generate all the keys. This is robust under network loss, as long as your sequence number wrapping scheme is robust.
enum Bool { True, False, FileNotFound };
Advertisement
Good?That depends on you need.The encryption algorithms mentioned are a bit complex.

Quote:

In fact,what I want to know is algorithm which is for free and has a key.


Well key based algorithms are complex so if you cant implement or plug them into your code you could use simpler encryptions which are password based.
______________________________________________________________________________________________________
[AirBash.com]
Simply taking the key, repeating it till it's as long as the data, and XORing it with the data, is an encryption scheme with a key. And it isn't complex, either to implement or to crack ;)
RSA - the public key crypto system used in PGP.

Perl code for RSA (uses dc, an arbritary precision arithmetic package that ships with most UNIX systems):
print pack"C*",split/\D+/,`echo "16iII*o\U@{$/=$z;[(pop,pop,unpack"H*",<>)]}\EsMsKsN0[lN*1lK[d2%Sa2/d0<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<J]dsJxp"|dc`

Just an example that it's not too hard to use public/private key encryption. The biggest problem is to generate the keys (You need 2 LARGE primes)


Quote:
FireNet: The encryption algorithms mentioned are a bit complex.


No, in fact, TEA is one of the simplest algorithms there is, apart from XOR. Meanwhile, TES is cryptographic strength, and XOR isn't. Just for completeness, the source code for X-TEA is here:

// XTEA encryption algorithm from // http://www.simonshepherd.supanet.com/source.htm#new_ansi//// v == input (two 32-bit words per block)// w == output (two 32-bit words per block)// k == key (four 32-bit words)void xtea_encipher(    const unsigned int *const v,    unsigned int *const w,    const unsigned int * const k){  register unsigned int       y=v[0],z=v[1],sum=0,delta=0x9E3779B9,n=32;  while(n-->0)  {    y += (z << 4 ^ z >> 5) + z ^ sum + k[sum&3];    sum += delta;    z += (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3];  }  w[0]=y; w[1]=z;}// v == input (two 32-bit words per block)// w == output (two 32-bit words per block)// k == key (four 32-bit words)void xtea_decipher(    const unsigned int *const v,    unsigned int *const w,    const unsigned int * const k){  register unsigned int       y=v[0],z=v[1],sum=0xC6EF3720,  delta=0x9E3779B9,n=32;  /* sum = delta<<5, in general sum = delta * n */  while(n-->0)  {    z -= (y << 4 ^ y >> 5) + y ^ sum + k[sum>>11 & 3];    sum -= delta;    y -= (z << 4 ^ z >> 5) + z ^ sum + k[sum&3];  }  w[0]=y; w[1]=z;}


You may note that it's block-based; I mistakenly suggested it was stream based in my previous reply; it's the key-mutating versions of (X)TEA which are stream-based. The basic, block-based algorithm shown here is much more suitable for a lossy network.


Quote:
FireNet: key based algorithms are complex so if you cant implement or plug them into your code you could use simpler encryptions which are password based


There is no difference between a "password" and a "key". If you think a "password" is a sequence of ASCII characters, and a "key" is an arbitrary sequence of bytes, then you can easily turn a password into a key (concatenating byte values), and vice versa (think uuencode).

Perhaps you meant to say "public key based algorithms"? If so, it still doesn't make sense, because nobody had suggested a public key cryptosystem before your post.
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement