Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

My encryption in C

Name: Anonymous 2007-02-04 13:25

// discuss
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void flip(char *str) {
   
    int i = -1, o = strlen(str);
    char temp;
   
    while((--o - ++i) >= 0) {
        temp = str[i];
        str[i] = str[o];
        str[o] = temp;
    }
   
}

void rot(char *str, int number) {
   
    int i;
    number %= 26;
   
    for(i=0; i<strlen(str); i++)
       
        if(isupper(str[i])) {
        if(!isupper(str[i] += number))
            str[i] -= 26;
        }
       
        else if(islower(str[i])) {
            if(!islower(str[i] += number))
                str[i] -= 26;
        }
}

int encrypt(char *filepath, char *encrypted) {
   
    FILE *fp, *fp2;
    char *buffer;
    long filesize;
    int i = -1;
   
    if(!(fp = fopen(filepath, "rb"))) {
        fprintf(stderr, "Can't access %s\n", filepath);
        return 1;
    }
   
    if(!(fp2 = fopen(encrypted, "w"))) {
        fprintf(stderr, "Can't write to %s\n", encrypted);
        fclose(fp);
        return 2;
    }
   
    fseek(fp, 1, SEEK_END);
    filesize = ftell(fp);
    rewind(fp);

    buffer = (char*)malloc(filesize+1);
   
    fread(buffer, 1, filesize, fp);
    fclose(fp);
   
    while(buffer[++i])
        if(islower(buffer[i]))
            buffer[i] = 219 - buffer[i];
        else if(isupper(buffer[i]))
            buffer[i] = 155 - buffer[i];
        else if(isdigit(buffer[i]))
            buffer[i] = 105 - buffer[i];
       
    flip(buffer);
    rot(buffer, 13);
   
    fputs(buffer, fp2);
    free(buffer);
    fclose(fp2);
   
    return 0;
}

main(int argc, char **argv) {
    encrypt(argv[1], argv[2]);
}

Name: Anonymous 2007-02-04 13:46

// discuss
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int encrypt(char *filepath, char *encrypted) {
  
    FILE *fp, *fp2;
    char *buffer;
    long filesize;
    int i = -1;
    int x = -1;
  
    if(!(fp = fopen(filepath, "rb"))) {
        fprintf(stderr, "Can't access %s\n", filepath);
        return 1;
    }
  
    if(!(fp2 = fopen(encrypted, "w"))) {
        fprintf(stderr, "Can't write to %s\n", encrypted);
        fclose(fp);
        return 2;
    }
  
    fseek(fp, 1, SEEK_END);
    filesize = ftell(fp);
    rewind(fp);

    buffer = (char*)malloc(filesize+1);
    memset(buffer, 0, filesize+1);

    fread(buffer, 1, filesize, fp);
    fclose(fp);

    while(buffer[++i])
    {
        for(x = 0; x < (int)buffer[i]; x++)
            fputs("desu", fp2);
        fputs("^___^", fp2);
    }

    free(buffer);
    fclose(fp2);
  
    return 0;
}

main(int argc, char **argv) {
    encrypt(argv[1], argv[2]);
}

Name: Anonymous 2007-02-04 15:55

That's some remarkably shitty code you have there.

Name: Anonymous 2007-02-05 9:20

>>1
Hint: Implement DES

Name: Anonymous 2007-02-05 9:20

>>4
Stupid, I meant AES

Name: Anonymous 2007-02-05 10:22 (sage)

>>5
Serpent is better.

Name: Anonymous 2007-02-05 15:15

>>6
MD5 is better

Name: Anonymous 2007-02-05 19:27

>>7
brokan

Name: Anonymous 2007-02-05 23:58

>>1
That kind of encryption is dead. The problem is, with that, you have the method of encryption on a computer, and the method of decrypting on your recipient's computer. They can be hacked. The programs can be reverse-engineered to get the method. Then your encryption is about as good as ROT-26.

Name: Anonymous 2007-02-06 0:47

Don't roll your own. Use AES, Twofish or some such algorithm that's had some actual research and is a proper standard. If you're really paranoid, use separate key material for both and encrypt twice.

Name: Anonymous 2007-02-06 6:58

AES is developed by people who are smarter than you and me, tested for more hours than you and I have in our lives, and used by people that sum more money than we can even imagine. If it's secure for them, it's secure for us. For massive damage, do what >>10 said; that way you could afford to have one of the two "broken" (more like weakened by mathematical analysis to find a quicker way to find your key or an equivalent key).

Name: Anonymous 2007-02-06 11:50

        temp = str[i];
        str[i] = str[o];
        str[o] = temp;


lol, only fags use temp variables when swapping data

        *str[i] ^= *str[o];
        *str[o] ^= *str[i];
        *str[i] ^= *str[o];


VROMM VROOM FAST AND LESS MEMORY BEXCAUSE IT DOEST USE VARIABLES OOPS CFLAGS JUIST KICKED IN IM OFF BYEEEEEEEEEEEEEE~~~~~~

Name: Anonymous 2007-02-06 12:45

All of you suck. If he wants to write his own encryption lib, fine, it'll help him get forward. Just using software without trying to write your own is what Myspace users do.

Name: Anonymous 2007-02-06 13:58

I hope >>12 is being facetious.

Name: Anonymous 2007-02-06 15:11

>>14
Would he have mentioned CFLAGS otherwise?

Name: Anonymous 2007-02-06 17:13

>>12
enjoy your overflow errors :D

Name: Anonymous 2007-02-07 17:18

>>12
You must use Gentoo Linux...

Name: Anonymous 2007-02-07 18:26

>>17
You can't tell me what to do!

Name: Anonymous 2007-02-07 18:38

>>16
wut?

Name: Anonymous 2007-02-08 2:24

>>16
enjoy your not understanding anything about anything :D

Name: Anonymous 2009-01-14 13:10

LISP

Name: Anonymous 2009-03-06 5:33


That is powerfull i   heard of python   Nor aware of   I stand pleasantly?

Name: Anonymous 2012-03-23 23:37

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boyAll work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

All work and no play makes Jack a dull boy

Name: Sgt.Kabu뵫ᯑkiman濥읕 2012-05-28 22:16

Bringing /prog/ back to its people
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy

Don't change these.
Name: Email:
Entire Thread Thread List