define long variable and XOR

Hi my friend .....I am working by C++ recently ..I have one question. I want to write encryption algorithm.first af all I need to define variable( binary input ) that it is 256 bit but I dont know what should I use...then I want to XOR this to variable ( a & b ) ( each of them is 256 bit)
can any one help me?
it is very urgent.....thank you
Perhaps you could use std::bitset<256> to implement your algorithm?
Last edited on
I cant get your mean correctly..
I mean something like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <iostream>
#include <bitset>

int main()
{
   std::bitset<256> a, b;
   for(size_t n = 0 ; n < a.size(); ++n)
   {
        a[n] = n&2;
        b[n] = n&3;
   }
    std::cout << "a = " << a     << '\n'
              << "b = " << b     << '\n'
              << "a^b:" << (a^b) << '\n'
              << "a&b:" << (a&b) << '\n';
}
hi....first thanks for your attention..
I used your code & run it in this way

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#include <iostream>
#include <bitset>
#include<conio.h>
using namespace std;
int main()
{
   bitset<256> a,b;
   cout<< "Enter your key \n";
      cin>> a;
	  cout<<"Enter your plain text\n";
	  cin>> b;
	  for(size_t n = 0 ; n < a.size(); ++n)
   {
        a[n] = n&2;
        b[n] = n&3;
   }
	  cout << "a^b:" << (a^b) << '\n';
	  getch();
}



but it doesnt XOR truly...I cant underestand 7 to 10 lines of your code...what it means
?
thank you
7 to 10 lines of your code...what it means
those lines populated a and b with some arbitrary bit patterns, to give me something to demonstrate bitwise operators on
this problem solved ....than you
but I want to divided my XOR ansewr in to 4, 64 bit spaces....what should I do?
Topic archived. No new replies allowed.