my plaintext is first converted to binary text, then it should be divided into 64 bit blocks and the key has to encrypted tese blocks separately. for example, if my text has 90 bits it should be supplemented with zeros so that it has 128 bits. I do not know how to do this. here is my code:
string ifile = "filetxt.txt";
string ofile = "file2.txt";
string key = "keywordd";
vector<int> k;
vector<int> txt;
char text;
vector<int> o;
int i;
int c = 0;
int d = 1;
void f() {
ifstream ist ("filetxt.txt");
ofstream ost ("file2.txt");
int a[64], i;
while (ist >> text) {
for(char& text : key) {
for(i=0; i < 8; i++){
a[i] = text%2;
text = text/2;
}
for(i=i-1; i >= 0 ;i--){
k.push_back(a[i]);
}
}
if (ist) {
for(i=0; i < 8; i++){
a[i] = text%2;
text = text/2;
}
for(i=i-1 ;i >= 0 ;i--){
txt.push_back(a[i]);
}
for(int j = 0; j < 8; j++) {
if(k[j] == txt[j]) {
o.push_back(c);
} else if (k[j] != txt[j]) {
o.push_back(d);
}
}
for(i=0; i<8; i++) {
ost << o[i];
}
for(i=0; i<8; i++) {
cout << o[i];
}
}
}
cout << endl;
for(i=0; i<64; i++) {
cout << k[i];
}
cout << endl;
for(i=0; i<64; i++) {
cout << txt[i];
}
}
int main()
{
f();
return 0;
}
i was to do something like this:
if (txt.size()< 64){
for(i= 0; i< 64- txt.size();i++){
txt.push_back(c);
}
}
i think that the problem is in the txt vector because if i want to print it i