Can someone explain why this doesn't work?
Thanks!Code:#include <iostream.h> #include <string.h> char* encrypt(char *passD, char *phraseD); char* decrypt(char *passD, char *encryptedD); void main() { char *encrypted, pass[10], phrase[30], *passer, *phraser, choice; int x, d=0; cout << "\nPlease type a password:\n"; cin.getline(pass, 9); cout << "\nPlease type a phrase to encrypt:\n"; cin.getline(phrase, 29); passer = &pass[0]; phraser = &phrase[0]; encrypted = encrypt(passer,phraser); cout << "\n--------------------\nEncrypted phrase is:\n "<< encrypted; cout << "\n\nHey, this works!\n" << decrypt(passer, encrypted) << "\n"; } char* encrypt(char *passD, char *phraseD) { char encrypted[60]; int x, d = 0; for (x=0; x < strlen(phraseD); x++) { if(d > strlen(passD)) d = 0; encrypted[x] = *(phraseD+ x) ^ *(passD +d); d++; } return &encrypted[0]; } char* decrypt(char *passD, char *encryptedD) { char phrase[60]; int x, d = 0; for (x=0; x < strlen(encryptedD); x++) { if(d > strlen(passD)) d = 0; phrase[x] = *(encryptedD+ x) ^ *(passD +d); d++; } return &phrase[0]; }
sirSolarius



LinkBack URL
About LinkBacks


