So i did tons of research for bout 2 hours on google and finally figured out how bit-level works when using XOR, but most of the time, the vars were already declared I wanted to know how to declare them but by user input. This is just an example i managed to get it to work with pass, but as for key I am stuck. But see when I want to XOR pass ^ key I want the key to know the pass length and generate random symbols mixed with alpha-numeric either from a generator or specified array, instead of my already declared var "!@#$%^&". Here is my code:
// XORO.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <string.h>
#include <conio.h>
#include <cstring>
using namespace std;
char pass[32]; //pass will not always be 32 char in length
char key[32] = "!@#$%^&"; //length needs to match strlen of pass
int chLen;
int count = NULL;
int main()
{
cout << "Input your password: ";
cin >> pass; cout << endl;
cout << " You typed: " << pass << endl;
cout << "Sizeof password: " << strlen(pass) << endl;
chLen = strlen(pass);
//Count strlen for XOR encryption
cout << " # of Integers: " << chLen << endl;
//To make sure that the size of pass is stored in chLen.
cout << "X-OR Encryption: ";
for ( count = NULL; count < chLen; count++)
{
pass[count] = pass[count] ^ key[count];
cout << pass[count];
} cout << endl << endl;
cout << " X-OR Reveresed: ";
for ( count = NULL; count < chLen; count++)
{
pass[count] = key[count] ^ pass[count];
cout << pass[count];
} cout << endl << endl;
_getch();
return 0;
}
Any insight will help. Much appreciated.