Link to home
Start Free TrialLog in
Avatar of mrwad99
mrwad99Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Encrypt and decrypt a CString

Ah hello.

I am looking for an algorithm that can encrypt and decrypt a CString.  The thing is, this CString may be as simple as a "1" or "0", so I am looking for something that will obviously increase the length of it if necessary.

Can someone link or list suitable code please ?  I have looked around via Google and not come up with anything suitable.

TIA
Avatar of Jaime Olivares
Jaime Olivares
Flag of Peru image

You need a symetrical block cipher, like IDEA or 3DES by example, minimum result is a 64 bytes block even for a 1 char string, also you can pad "random garbage" to the string to complete 8 bytes (64 bits) to avoid to be hacked with repetitive short messages like "1" or "0".
Avatar of mrwad99

ASKER

Right, so where can I find example code ?
Here you have DES/3DES theory:
http://kingkong.me.berkeley.edu/~kenneth/courses/sims250/des.html

Here some source code of DES (I suggest to use DES instead of 3DES because it is simpler and faster, unless you have a critical requirement):
http://www.ussrback.com/crypto/cracking-des/cracking-des/ch5/des.c
Avatar of mrwad99

ASKER

Thanks.

OK cool, will read that shortly.  In the meantime, if anyone has any other code suggestions, please post.
Avatar of mrwad99

ASKER

preferably something simple...:-)
don't have to understand so much, just copy/paste and adapt
SOLUTION
Avatar of jj819430
jj819430

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrwad99

ASKER

Thanks all :)