?? open.cpp
字號:
// open.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>
#include <stdio.h>
#include <conio.h>
unsigned char kkk[8];
unsigned char buffer[600],ch_buffer[600];
unsigned byteswritten;
unsigned char read_buff[8];
unsigned char read_char;
int main(int argc, char* argv[])
{
int fh1, fh2;
unsigned int i,j=0;
unsigned int nbytes = 600, bytesread;
for(i=0;i<8;i++)
{
read_buff[i] = '\0';
}
for(i=0;i<8;i++)
{
read_char = _getch();
if( read_char == '\r')
break;
read_buff[i]=read_char;
}
kkk[0] =0x12^read_buff[0];//
kkk[1] =0x25^read_buff[1];
kkk[2] =0x7d^read_buff[2];
kkk[3] =0xde^read_buff[3];
kkk[4] =0x3e^read_buff[4];
kkk[5] =0xb2^read_buff[5];
kkk[6] =0xc4^read_buff[6];
kkk[7] =0x93^read_buff[7];
fh1 = _open( "22.rao", _O_RDONLY|_O_BINARY );
if( fh1 == -1 )
{
perror( "open failed on input file" );
return(-1);
}
fh2 = _open( "22.rar", _O_RDWR | _O_CREAT|_O_TRUNC|_O_BINARY );//, _S_IREAD| _S_IWRITE
if( fh2 == -1 )
{
perror( "Open failed on output file" );
return(-1);
}
while(1)
{
bytesread = _read(fh1,buffer,nbytes);
if(bytesread == -1)
{
perror( "read failed on output file" );
return(-1);
}
for(i= 0 ; i < bytesread ; i++)//轉換
{
ch_buffer[i] = buffer[i]^kkk[j];
j++;
if(j==8)
j = 0 ;
}
if(bytesread !=0)
{
byteswritten = _write(fh2,&ch_buffer[0],bytesread);
if(byteswritten==-1)
{
perror( "write failed on output file" );
return(-1);
}
}
if(bytesread < nbytes)
break;
}
_close( fh1 );
_close( fh2 );
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -