Can anybody see why strlen(Encrypted) should return 24?
Code:#include <stdio.h> #include <conio.h> #include <string.h> void XOREncrypt(const char*, const char*, char*); void XOREncrypt(const char* Text, const char* Key, char* Out) { long CurIndex = 0, KeyIndex = 0; delete[] Out; Out = new char[strlen(Text)]; for(CurIndex = 0; CurIndex < strlen(Text); CurIndex++) { Out[CurIndex] = Text[CurIndex] ^ Key[KeyIndex]; KeyIndex++; if(KeyIndex == strlen(Key)) KeyIndex = 0; } } int main() { char* Encrypted = new char; char Text[] = "testing", Key[] = "xSquared"; XOREncrypt(Text,Key,Encrypted); printf("%s XOR %s = %ld", Text, Key, strlen(Encrypted)); getch(); return 0; }



LinkBack URL
About LinkBacks


