Suntuubi-palvelussa käytetään evästeitä. Palvelua käyttämällä hyväksyt evästeiden käytön. Lue lisää. OK

// Numdecrypt 0.5 beta

/* Numdecrypt on LJ:n tekemä ohjelma joka purkaa saluksen

numencryptillä salatusta luvusta.*/

/* Include the libraries */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
/* Variables to be used in the hole program --------------------------*/
long int number = 0;
unsigned short int seeds = 0;
char rd = ' ';
long int x = 0;
long int y = 0;
long int z = 0;
long int a = 0;
long int b = 0;
long int c = 0;
long int d = 0;
long int e = 0;
long int f = 0;
long int g = 0;
long int xy = 0;
long int yx = 0;
long int ab = 0;
long int xz = 0;
long int yy = 0;
long int zx = 0;
long int zy = 0;
/* Functions begin. -----------------------------------------------*/
void save (void) {
     char fname [150];
     FILE *fp;
     printf("Where do you want to save the decrypted number? (file path)\nDoesnt need to exist\n");
     scanf ("%s", &fname);
     if ( (fp = fopen( fname, "a" ) ) != NULL) {
          fprintf( fp, "%d", number);
}
else {
     printf("Error while prosessing the file!\n");
}
fclose (fp);
}
/* main, program begins --------------------------------------- */
int main (void) {
printf("How many seeds you used?\n");
scanf("%d", &seeds);
switch (seeds) {
       case 1:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
             break;
       case 2:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            break;
       case 3:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            printf("Gimme seed z!\n");
            scanf("%d", &z);
            break;
       case 4:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            printf("Gimme seed z!\n");
            scanf("%d", &z);
            printf("Gimme seed a!\n");
            scanf("%d", &a);
            break;
       case 5:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            printf("Gimme seed z!\n");
            scanf("%d", &z);
            printf("Gimme seed a!\n");
            scanf("%d", &a);
            printf("Gimme seed b!\n");
            scanf("%d", &b);
            break;
       case 6:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            printf("Gimme seed z!\n");
            scanf("%d", &z);
            printf("Gimme seed a!\n");
            scanf("%d", &a);
            printf("Gimme seed b!\n");
            scanf("%d", &b);
            printf("Gimme seed c!\n");
            scanf("%d", &c);
            break;
       case 7:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            printf("Gimme seed z!\n");
            scanf("%d", &z);
            printf("Gimme seed a!\n");
            scanf("%d", &a);
            printf("Gimme seed b!\n");
            scanf("%d", &b);
            printf("Gimme seed c!\n");
            scanf("%d", &c);
            printf("Gimme seed d!\n");
            scanf("%d", &d);
            break;
       case 8:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            printf("Gimme seed z!\n");
            scanf("%d", &z);
            printf("Gimme seed a!\n");
            scanf("%d", &a);
            printf("Gimme seed b!\n");
            scanf("%d", &b);
            printf("Gimme seed c!\n");
            scanf("%d", &c);
            printf("Gimme seed d!\n");
            scanf("%d", &d);
            printf("Gimme seed e!\n");
            scanf("%d", &e);
            break;
       case 9:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            printf("Gimme seed z!\n");
            scanf("%d", &z);
            printf("Gimme seed a!\n");
            scanf("%d", &a);
            printf("Gimme seed b!\n");
            scanf("%d", &b);
            printf("Gimme seed c!\n");
            scanf("%d", &c);
            printf("Gimme seed d!\n");
            scanf("%d", &d);
            printf("Gimme seed e!\n");
            scanf("%d", &e);
            printf("Gimme seed f!\n");
            scanf("%d", &f);
            break;
       case 10:
            printf("Gimme seed x!\n");
            scanf("%d", &x);
            printf("Gimme seed y!\n");
            scanf("%d", &y);
            printf("Gimme seed z!\n");
            scanf("%d", &z);
            printf("Gimme seed a!\n");
            scanf("%d", &a);
            printf("Gimme seed b!\n");
            scanf("%d", &b);
            printf("Gimme seed c!\n");
            scanf("%d", &c);
            printf("Gimme seed d!\n");
            scanf("%d", &d);
            printf("Gimme seed e!\n");
            scanf("%d", &e);
            printf("Gimme seed f!\n");
            scanf("%d", &f);
            printf("Gimme seed g!\n");
            scanf("%d", &g);
            break;
       default:
               printf("incorrect value, exiting!");
               return 0;
}
printf("gimme the number to decrypt!\n");
scanf("%d", &number);
switch (seeds) {
       case 1:
            number = (number - x);
            number = (number - 37532);
            number = (number - x);
            number = (number + 94573);
            number = (number - x);
            number = (number - 891);
            number = (number + x);
            break;
       case 2:
            xy = (x + y);
            xy = (xy - 154);
            number = (number + 986);
            number = (number - y);
            number = (number - 894356);
            number = (number + x);
            number = (number - y);
            number = (number - xy );
            break;
       case 3:
            number = (number - 17659);
            number = (number - y);
            number = (number + xz);
            xz = (x + z);
            number = (number - 186);
            number = (number - y);
            number = (number + z);
            break;
       case 4:
            yx = (x - y);
            number = (number - 89543);
            number = (number - x);
            number = (number - z);
            number = (number - z);
            number = (number + a);
            number = (number + yx);
            break;
       case 5:
            yy = (y * 2);
            zx = (z - x);
            number = (number - 1);
            number = (number - 896543);
            number = (number + b);
            number = (number - a);
            number = (number - zx);
            number = (number + yy);
            break;
       case 6:
            number = (number + y);
            number = (number - y);
            number = (number - c);
            number = (number + z);
            number = (number - c);
            number = (number + b);
            number = (number + x);
            number = (number - y);
            number = (number + b);
            number = (number + a);
            number = (number - y);
            break;
       case 7:
            number = (number + b);
            number = (number - 134);
            zy = (z + y);
            number = (number - d);
            number = (number - c);
            number = (number + a);
            number = (number + zy);
            number = (number - y);
            number = (number + x);
            break;
       case 8:
            number = (number + y);
            number = (number + x);
            number = (number - c);
            number = (number - b);
            number = (number + d);
            number = (number + 1);
            number = (number - 6529);
            number = (number + z);
            number = (number - a);
            number = (number - e);
            break;
       case 9:
            xy = (x - y);
            ab = (a + b);
            number = (number - f);
            number = (number - e);
            number = (number + d);
            number = (number - c);
            number = (number + z);
            number = (number - 785221);
            number = (number + ab);
            number = (number - xy);
            break;
       case 10:
            xy = (y - x);
            ab = (a - b);
            xy = (xy - ab);
            number = (number + 143);
            number = (number + g);
            number = (number - f);
            number = (number + 1);
            number = (number + e);
            number = (number - c);
            number = (number - d);
            number = (number + z);
            number = (number - 15973);
            number = (number + xy);
            number = (number + xy);
            break;
       default:
               printf("Incorrect value, exiting!\n");
               return 0;
               break;
}           
printf("The decrypted number is ");
printf("%d", number);
printf(". Do you want to save decrypted number in a file?\nS to save\n");
rd = getch();
switch (rd) {
       case 'S': case 's':
            save();
            break;
       default:
               break;
}
return 0;
}


©2017 Ohjelmointi ja modaussivut - suntuubi.com