Добавил:
korayakov
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз:
Предмет:
Файл:
#include <iostream>
#include <fstream>
using namespace std;
int main(){
fstream in;
in.open("10.bmp",ios::in|ios::binary);
if(!in){
cout<<"io error"<<endl;
return 1;
}
char c;
int a=0;
int b=0;
int x;
int k;
long key[8];
int cum;
long move=1;
x=cum=0;
k=0;
x=31;
cout<<"start"<<endl;
while((in.get(c))){
a++;
if(a>(0xac60)&&a<=(0xad40)){
if(c&(1<<(0)))
cout<<'1';
else
cout<<'0';
cum+=(move<<(31-x))*(c&1);
x--;
if(x<0){
key[k++]=cum;
cum=0;
x=31;
}
b++;
}
}
fstream out("key.txt", ios::out|ios::binary);
for(int i=0;i<7;i++)
out.write(&key[i],4);
long l=0x00000000;
out.write(&l,4);
cout<<endl<<b;
in.close();
return 0;
}