Esempio n. 1
0
void dechiffre(char* fentree, char* cle, char* fsortie)
{
	
	int i;
	int taille = strlen(cle);
	char* cleInv = malloc(taille*sizeof(char));

	for(i=0; i<taille; i++)
	{
		cleInv[i] = (26-cle[i]+'A')%26+'A';
	}
	
	chiffre(fentree, cleInv, fsortie);
}
Esempio n. 2
0
int main(int argc, char *argv[])
{
	if(argc < 4)
	{
		return 0;
	}

	if(strcmp(argv[1], "-ch") == 0)
	{
		chiffre(argv[2], argv[3], argv[4]);
	}

	if(strcmp(argv[1], "-d") == 0)
	{
		dechiffre(argv[2], argv[3], argv[4]);
	}

	if(strcmp(argv[1], "-dp") == 0)
	{
		decrypte(argv[2], argv[3]);
	}
 }
char *repr_nombre(int n, int  b)
{
	//Avec des division euclidienne
	char *rep = malloc(sizeof(char));
	char *tmp;
	int q = n;
	int r = 0;
	int index = 0;
	while(q!=0)
	{
		r = q%b;
		if(!realloc(rep, strlen(rep)+1)){
			printf("erreur realloc");
		}
		tmp = malloc(sizeof(char) * strlen(rep));
		strcat(tmp, rep);
		rep[0] = chiffre(r);
		strcat(rep, tmp);
		free(tmp);
		q = q/b;
	}
	return rep;
}