1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| /**************************************************************************/
/* Fonction applyKey */
/**************************************************************************/
void applyKey(char * password, char * resultat, int length, char * cle)
{
int i;
// ou exclusif bit par bit du pwd formule :
//pwd_crypter = pwd_clair ^ cle
//pwd_clair = pwd_crypter ^ cle
for(i = 0; i < length; i++) {
resultat[i] = password[i] ^ cle[i] ;
}
}
/**************************************************************************/
/* Fonction Coder / Decodeer pwd */
/**************************************************************************/
char * Coder_Decoder(char * pwdCrypter, char * key){
char* res;
unsigned char in[100];
unsigned char out[100];
int i;
memcpy(in, pwdCrypter, 8);
applyKey(in, out, 8, key);
for(i=0;i<length;i++){
printf("\n decodage : out[%d]:%c",i,out[i]);
}
length = strlen(out);
out[8]='\0';
res=out;
printf("\n resultat de coder Decoder : %s",res);
return(res);
} |
Partager