Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple scantime crypting source code
#1
Well hackforums.net is down atm and i'm bored. Jus a simple code to let you guys see how to encrypt an entire file and put in in a different file encrypted, which you can then decrypt it. It's not the scantime crypter source code with stub and builder but just the encryption decryption function.

Code:
/// rot 128
int Rot128_FileToFile(char *Filename_In, char *Filename_Out)
{
    FILE *Copy = fopen(Filename_In, "rb");
    FILE *Paste = fopen(Filename_Out, "wb");
    if(!Copy || !Paste)
        return -1;

    int c;
    while((c = fgetc(Copy)) != EOF)
    {
        // works with 128, 120 too weird.
        if(c >= 0 && c <= 127)
            c+=128;
        else c-=128;

        fprintf(Paste, "%c", c);
    }

    fclose(Copy);
    fclose(Paste);
    return 1;
}

Let me know what you guys think.
Reply
#2
Looks pretty pimp, dude. As far as complexity, the algorithm isn't very strong, but I like your coding style. Does:
Code:
while((c = fgetc(Copy)) != EOF)
actually work? Using an assignment operator in conjuction with a comparison operator, all as part of a conditional? Never seen that before.
Reply
#3
(01-19-2010, 08:10 PM)J4P4NM4N Wrote: Does Using an assignment operator in conjuction with a comparison operator, all as part of a conditional?

It's valid C/C++ so it works fine. It's use can sometimes be frowned upon (the coding standards where I worked disallowed doing it) because it can be troublesome to read when you are scanning code, but it works in this case since it prevents code duplication.
[Image: sig.php]
The little boat gently drifted across the pond exactly the way a bowling ball wouldn't.
Reply
#4
I see. I can also see why it was frowned upon, hehe.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [C++] Port Scanner [SOURCE CODE] flAmingw0rm 36 13,831 04-07-2013, 07:46 PM
Last Post: TheArmyKid
  [C++ Source Code] Keyboard Spammer. Yin 9 5,294 08-26-2010, 10:33 AM
Last Post: Yang-

Forum Jump:


Users browsing this thread: 1 Guest(s)