need some really simple text encryption method.

Started by
9 comments, last by Evil Steve 18 years ago
Hello. I need a really simple text encryption method. I know nothing of encryption, and all i need it for is to make it humanly unreadable. It doesn't have to be secure at all, ease of implementation is most important. It also need to be possible to decrypt just a piece of the entire "file". For instance, sometime i may not read the entire encrypted content of the file, just a small part. So the "key" or whatever you use can't be based on having the entire file. For instance, if i fread() just 20 bytes of encrypted text. I need to be able to decode that without reading anything more. So if someone has a really simple implementation of this to offer me. It would be greatly appreciated++. :-) Thanks in advance.
Shields up! Rrrrred alert!
Advertisement
A simple substitution cipher? rot13 (A => N, B => O etc)?
Depend. If you really only want to decrpyt/encrypt text I'd suggest using one of the more simple methods like Caesars Cypher. (This and other very simple methods are explained here: http://www.cs.usask.ca/resources/tutorials/csconcepts/1999_3/lessons/L3/SimpleEncryption.html).

If you are trying to use a (very) simple binary encryption method just xor your Data with a aribtrary key.

Hope that helps. Greetings, Roga

TEA's nice and easy - although it works on 64 bit chunks, so you'd need to pad your text, and include a length header in the encrypted block.
Winterdyne Solutions Ltd is recruiting - this thread for details!
XOR encryption will do the job. Something like this:
void XorEncrypt(void* pBuffer, size_t nLen, unsigned char byKey){   unsigned char* pBuff = (unsigned char*)pBuffer;   for(size_t i=0; i<nLen; ++i)      *pBuff++ ^= byKey;}// Use like so:char buffer[20];fread(buffer,1,20,pFile);XorEncrypt(buffer,20,255);

You decrypt and encrypt using the same function (I.e. you XOR twice). My function will only let you use a key of 0..255, if you want something else, or a password, you'd have to xor with each character of the password. So you'd do "Hidden Data" (xor'd with) "PasswordPas"; I.e. repeat the password to make it the length of the data.
If I'm right he wanted text encyption. The suggeste XOR encryotion is a binary method. So if he want's to keep it simple and human readable Caesar seems pretty fine to me.
Quote:Original post by Rogalon
If I'm right he wanted text encyption. The suggeste XOR encryotion is a binary method. So if he want's to keep it simple and human readable Caesar seems pretty fine to me.

Quote:I know nothing of encryption, and all i need it for is to make it humanly unreadable.
I took that to mean that he doesn't want it to be text at all. I suppose it can be taken both ways though. But yes, a Caesar cyper would certainly be fine if he wants the output to be human readable, or at least ASCII.
thank you all for your replies! The xor method looks exactly like what i was looking for, nice and simple.


Again, thanks!
Shields up! Rrrrred alert!
I've seen base64 used as a simple "encryption method" that keeps the output in ASCII.

There is also always the classic rot13.

Both have the advantage (or disadvantage...) of having plenty of sample implementations floating around to reuse.
-Mike
Ebg guvegrra vf gur orfg plcure.
Abobql pna qrsrng ebg guvegrra.

This topic is closed to new replies.

Advertisement