Archived

This topic is now archived and is closed to further replies.

DimSum

A light, encryption algorithm??

Recommended Posts

Hi all, I have a program that writes some simple text to a file. But I want to encrypt the text before writing the text into the file. Does anyone know where I can find a light encryption algorithm code that I can use to encrypt my text before writing it the file?? Like some encrytion code that I can throw into my program and use? thanks all. -Phil

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Generate a Key and Xor it byte for byte. Modulus may be need if the data is longer than key.

Share this post


Link to post
Share on other sites
This one is really easy, and probably very simple to crack for a professional. But it will prevent your files to be read by any normal user.


srand(key);

for( ...loop through your data... ) {
enc = (*data++) ^ (rand()&0xFF);
write enc to the file
}


If security is important, then go here. I would recommend RC5/6, IDEA or Blowfish.


[edited by - Yann L on October 17, 2002 8:32:11 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by Yann L
srand(key);
for( ...loop through your data... ) {
enc = (*data++) ^ (rand()&0xFF);
write enc to the file
}

It isn't always obvious how to decrypt this, to someone who hasn't seen it before. You would simply do something like this:


//read file into data, which is usually a pointer to char array
srand(key); //use same key as used to encrypt
for(...loop for every byte...)
{
decryptedData = (*data++) ^ (rand()&0xFF);
decryptedData++; //decryptedData is another ptr to char array
}


[edited by - Neosmyle on October 17, 2002 8:38:10 PM]

Share this post


Link to post
Share on other sites