Chiffrement de fichiers textes lettre par lettre. Plusieurs algorithmes sont utilisés. La sécurité produite est inadaptée à un usage autre que personnel.
Source / Exemple :
/*=============================================================*\
|| Crypt-o-matic v1.2 "DarkChocolate", GAUTHIER Francois, 2009 ||
||=============================================================||
|| ||
|| Automated Data Encryption Tool ||
|| (Do not provide real security, use it for fun) ||
\*=============================================================*/
#include <stdio.h>
#include <time.h>
#include <stdlib.h>
//==================================================================// "Be positive!" fonction
void bePlus(long *g)
{
}
//==================================================================// Encoding fonction
void fct(char *p, unsigned long *k, unsigned long *l)
{
long sort=0;
unsigned long gap=0;
//----------------------------------------------------// Selection tool
sort = lrand48()%1000000+random()%10000; // "Randomly" select the encoding method
if (sort<0)
{
bePlus(&sort); // Sort is always positive
}
//----------------------------------------------------// The methods
if (sort%2==0 || sort%37==0 || sort%937==0 ||
sort%379==0 || sort%383==0 || sort%389==0 ||
sort%397==0 || sort%401==0 || sort%409==0 ||
sort%449==0 || sort%457==0)
{
gap=lrand48()-*k-*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%3==0 || sort%41==0 || sort%941==0 ||
sort%751==0 || sort%757==0 || sort%419==0 ||
sort%421==0 || sort%431==0 || sort%433==0 ||
sort%439==0 || sort%443==0)
{
gap=random()-*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%5==0 || sort%43==0 || sort%947==0 ||
sort%461==0 || sort%463==0 || sort%467==0 ||
sort%479==0 || sort%487==0 || sort%491==0 ||
sort%499==0 || sort%503==0 || sort%509==0)
{
gap=lrand48()-rand()+*k-*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%7==0 || sort%47==0 || sort%953==0 ||
sort%263==0 || sort%269==0 || sort%271==0 ||
sort%277==0 || sort%281==0 || sort%283==0)
{
gap=random()-rand()-*k;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%11==0 || sort%53==0 || sort%967==0 ||
sort%563==0 || sort%569==0 || sort%571==0 ||
sort%577==0 || sort%587==0 || sort%593==0 ||
sort%599==0 || sort%601)
{
gap=lrand48()-random()-*k+*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%13==0 || sort%59==0 || sort%971==0 ||
sort%907==0 || sort%911==0 || sort%919==0 ||
sort%929==0)
{
gap=lrand48()-*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%17==0 || sort%61==0 || sort%977==0 ||
sort%701==0 || sort%709==0 || sort%719==0 ||
sort%727==0 || sort%733==0 || sort%739==0 ||
sort%743==0)
{
gap=lrand48()-*k-*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%19==0 || sort%67==0 || sort%983==0 ||
sort%823==0 || sort%827==0 || sort%829==0 ||
sort%839==0 || sort%853==0 || sort%857==0)
{
gap=rand()+*k;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%23==0 || sort%71==0 || sort%991==0 ||
sort%809==0 || sort%811==0 || sort%821==0)
{
gap=random()+*k+*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%29==0 || sort%73==0 || sort%997==0 ||
sort%773==0 || sort%787==0 || sort%797==0)
{
gap=rand()-*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%31==0 || sort%79==0 || sort%1009==0 ||
sort%761==0 || sort%769==0)
{
gap=rand()+*l-*k;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%83==0 || sort%89==0 || sort%97==0 ||
sort%331==0 || sort%337==0 || sort%347==0 ||
sort%349==0 || sort%353==0 || sort%359==0 ||
sort%367==0 || sort%373==0)
{
gap=random()-rand()+*k;
if(gap<0)
{
bePlus(&gap);
}
}
if(sort%101==0 || sort%103==0 || sort%107==0 ||
sort%229==0 || sort%233==0 || sort%239==0 ||
sort%241==0 || sort%251==0 || sort%257==0 ||
sort%293==0 || sort%307==0 || sort%311==0 ||
sort%313==0 || sort%317==0)
{
gap=lrand48()-random()+*k-*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%109==0 || sort%113==0 || sort%127==0 ||
sort%659==0 || sort%661==0 || sort%673==0 ||
sort%677==0 || sort%683==0 || sort%691==0)
{
gap=(*k)-*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%131==0 || sort%137==0 || sort%139==0 ||
sort%859==0 || sort%863==0 || sort%877==0 ||
sort%881==0 || sort%883==0 || sort%887==0)
{
gap=*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%149==0 || sort%151==0 || sort%157==0 ||
sort%461==0 || sort%463==0 || sort%467==0 ||
sort%479==0 || sort%487==0 || sort%491==0 ||
sort%499==0 || sort%503==0)
{
gap=*l+*k;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%163==0 || sort%167==0 || sort%173==0 ||
sort%643==0 || sort%647==0 || sort%653==0)
{
gap=*k*(*l);
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%179==0 || sort%181==0 || sort%191==0 ||
sort%607==0 || sort%613==0 || sort%617==0)
{
gap=*k+2;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%193==0 || sort%197==0 || sort%199==0 ||
sort%509==0 || sort%521==0 || sort%523==0 ||
sort%541==0 || sort%547==0 || sort%557==0)
{
gap=rand()+*k+*l;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%211==0 || sort%223==0 || sort%227==0 ||
sort%619==0 || sort%631==0 || sort%641==0)
{
gap=random()+*k+*l;
if(gap<0)
{
bePlus(&gap);
}
}
}
//=============================================================// Decoding fonction
void dfct(int *q, unsigned long *e, unsigned long *o)
{
long sort=0;
unsigned long gap=0;
//----------------------------------------------------// Selection tool
sort = lrand48()%1000000+random()%10000; // "Randomly" select the decoding method (Laughts are not allowed.)
if (sort<0)
{
bePlus(&sort); // Sort is always positive
}
//----------------------------------------------------// The methods
if (sort%2==0 || sort%37==0 || sort%937==0 ||
sort%379==0 || sort%383==0 || sort%389==0 ||
sort%397==0 || sort%401==0 || sort%409==0 ||
sort%449==0 || sort%457==0)
{
gap=lrand48()-*e-*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%3==0 || sort%41==0 || sort%941==0 ||
sort%751==0 || sort%757==0 || sort%419==0 ||
sort%421==0 || sort%431==0 || sort%433==0 ||
sort%439==0 || sort%443==0)
{
gap=random()-*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%5==0 || sort%43==0 || sort%947==0 ||
sort%461==0 || sort%463==0 || sort%467==0 ||
sort%479==0 || sort%487==0 || sort%491==0 ||
sort%499==0 || sort%503==0 || sort%509==0)
{
gap=lrand48()-rand()+*e-*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%7==0 || sort%47==0 || sort%953==0 ||
sort%263==0 || sort%269==0 || sort%271==0 ||
sort%277==0 || sort%281==0 || sort%283==0)
{
gap=random()-rand()-*e;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%11==0 || sort%53==0 || sort%967==0 ||
sort%563==0 || sort%569==0 || sort%571==0 ||
sort%577==0 || sort%587==0 || sort%593==0 ||
sort%599==0 || sort%601)
{
gap=lrand48()-random()-*e+*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%13==0 || sort%59==0 || sort%971==0 ||
sort%907==0 || sort%911==0 || sort%919==0 ||
sort%929==0)
{
gap=lrand48()-*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%17==0 || sort%61==0 || sort%977==0 ||
sort%701==0 || sort%709==0 || sort%719==0 ||
sort%727==0 || sort%733==0 || sort%739==0 ||
sort%743==0)
{
gap=lrand48()-*e-*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%19==0 || sort%67==0 || sort%983==0 ||
sort%823==0 || sort%827==0 || sort%829==0 ||
sort%839==0 || sort%853==0 || sort%857==0)
{
gap=rand()+*e;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%23==0 || sort%71==0 || sort%991==0 ||
sort%809==0 || sort%811==0 || sort%821==0)
{
gap=random()+*e+*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%29==0 || sort%73==0 || sort%997==0 ||
sort%773==0 || sort%787==0 || sort%797==0)
{
gap=rand()-*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%31==0 || sort%79==0 || sort%1009==0 ||
sort%761==0 || sort%769==0)
{
gap=rand()+*o-*e;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%83==0 || sort%89==0 || sort%97==0 ||
sort%331==0 || sort%337==0 || sort%347==0 ||
sort%349==0 || sort%353==0 || sort%359==0 ||
sort%367==0 || sort%373==0)
{
gap=random()-rand()+*e;
if(gap<0)
{
bePlus(&gap);
}
}
if(sort%101==0 || sort%103==0 || sort%107==0 ||
sort%229==0 || sort%233==0 || sort%239==0 ||
sort%241==0 || sort%251==0 || sort%257==0 ||
sort%293==0 || sort%307==0 || sort%311==0 ||
sort%313==0 || sort%317==0)
{
gap=lrand48()-random()+*e-*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%109==0 || sort%113==0 || sort%127==0 ||
sort%659==0 || sort%661==0 || sort%673==0 ||
sort%677==0 || sort%683==0 || sort%691==0)
{
gap=(*e)-*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%131==0 || sort%137==0 || sort%139==0 ||
sort%859==0 || sort%863==0 || sort%877==0 ||
sort%881==0 || sort%883==0 || sort%887==0)
{
gap=*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%149==0 || sort%151==0 || sort%157==0 ||
sort%461==0 || sort%463==0 || sort%467==0 ||
sort%479==0 || sort%487==0 || sort%491==0 ||
sort%499==0 || sort%503==0)
{
gap=*o+*e;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%163==0 || sort%167==0 || sort%173==0 ||
sort%643==0 || sort%647==0 || sort%653==0)
{
gap=*e*(*o);
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%179==0 || sort%181==0 || sort%191==0 ||
sort%607==0 || sort%613==0 || sort%617==0)
{
gap=*e+2;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%193==0 || sort%197==0 || sort%199==0 ||
sort%509==0 || sort%521==0 || sort%523==0 ||
sort%541==0 || sort%547==0 || sort%557==0)
{
gap=rand()+*e+*o;
if(gap<0)
{
bePlus(&gap);
}
}
if (sort%211==0 || sort%223==0 || sort%227==0 ||
sort%619==0 || sort%631==0 || sort%641==0)
{
gap=random()+*e+*o;
if(gap<0)
{
bePlus(&gap);
}
}
}
//=============================================================// MAIN FONCTION
int main (int argc, const char * argv[])
{
char c; // Encoded variable
int x=0; // Peanut variable
int f=0, cont=1; // Option variable -- Continue variable
int d=0; // Decoded variable
char n_source[100]; // Source file name
char n_dest[100]; // Destination file name
unsigned long accessCode=0; // Access code variable
unsigned long loop=0; // Scores loops
while(cont!=0)
{
puts("\n== Welcome to Crypt-o-Matic (v1.2 DarkChocolate)! Do you want to encode a file (1) or decode a file(2)?\n== Pls type 1 or 2 and press ENTER");
scanf("%d", &f);
srandom(2);
srand48(2); // Random fonctions resets
srand(3);
loop=0;
//---------------------------------------------------------------------// Encoding or Decoding options
if(f==1)
{
puts("== Access code generated: ** USER'S RESPONSABILITY TO USE ANY APPROPRIATE MEANS TO REMEMBER IT AND KEEP IT SECRET **");
printf("== ------- access code ----->> %ld", accessCode=time(0));
puts("\n== File to encode? (eventually including directory):");
}
if(f==2)
{
puts("======== WARNING: INCORRECT ENTRY MAY RESULT IN PERMANENT DATA LOSS!! =========");
puts("== Enter your access code:");
puts("== (Pls verify).");
scanf("%ld", &accessCode);
puts("== Access granted.");
puts("\n== File to decode? (eventually including directory):");
}
scanf("%100s", &n_source);
FILE* stream=fopen(n_source, "r");
//--------------------------------------------// Pointer return NULL on n_source
if(stream==NULL)
{
exit(puts("\n== FILE NOT FOUND\n== ***\tPlease verify file's name.***"));
}
//-------------------------------------------//
puts("\n== Destination file?");
scanf("%100s", &n_dest);
FILE* stream2=fopen(n_dest, "w");
puts("== Proceeding... Please wait...");
//--------------------------------------------------------------------// Encoding and Decoding calls and files writing
if(f==1)
{
char x1='P';
x1+=1;
printf("== 'P'= %c", x1);
fprintf(stream2, "%c", x1);
while (c=fgetc(stream), c!=EOF)
{
loop++;
fct(&c, &accessCode, &loop);
fprintf(stream2, "%c", c);
}
}
if(f==2)
{
char x1=fgetc(stream);
x1-=1;
printf("== %c", x1);
if(x1=='P')
{
while (d=fgetc(stream), d!=EOF)
{
loop++;
dfct(&d, &accessCode, &loop);
fprintf(stream2, "%c", d);
}
}
else
{
puts("Decoding status.... FAILED");
return EXIT_FAILURE;
}
puts("== Decoding status.... ok!");
remove(n_source);
if(remove(n_source))
{
puts("== Deleting source file..... ok!");
}
else
{
puts("== Unable to delete source file!\n== Deleting target file.");
remove(n_dest);
if(remove(n_dest))
{
puts("== Target file deleted.");
}
else
{
puts("== Unable to delete target file!\n");
}
}
}
fclose(stream);
fclose(stream2);
puts("== Exit status......ok!");
puts("\n\n== Press 1 and ENTER to use again.\n== Press 0 and ENTER to exit");
scanf("%d", &cont);
if (cont==0)
{
break;
}
}
return 0;
}
//=============================================//
//============ END OF SOURCE CODE =============//
//=============================================//
Conclusion :
J'en ai fait plusieurs versions, celle ci est la plus "aléatoirement chiffrée". Elle se nomme DarkChocolate.
Vous n'êtes pas encore membre ?
inscrivez-vous, c'est gratuit et ça prend moins d'une minute !
Les membres obtiennent plus de réponses que les utilisateurs anonymes.
Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.
Le fait d'être membre vous permet d'avoir des options supplémentaires.