Search results

'암호화'에 해당하는 글들

  1. 2006/09/12  공용체를 이용한 파일 암호화. (3)
공용체를 잠깐 봐보고, 암호화를 해보았다.
간단하게 각 1바이트의 4비트를 2개로 쪼개어, 앞뒤만 섞어준다.

||||||||  -> ||||||||

CFileException e;
CFile file,file2;
#pragma pack(1)
struct dbbit{
 unsigned int one:4; // 앞 4비트
 unsigned int two:4; // 뒤 4비트
}b;
union crpyt{
 char input[1];
 dbbit a;  // 1byte char와 공유하는 8비트
}temp;
#pragma pack()
if(!file.Open("c:\\temp\\1.txt",CFile::modeRead,&e)){
 return;
}
if(!file2.Open("c:\\temp\\2.txt",CFile::modeCreate|CFile::modeWrite,&e)){
 return;
}
int i=0;
while(file.GetLength()>i){
 file.Read(temp.input,1);  // 비트 교환
 b.two = temp.a.one;
 b.one = temp.a.two;
 temp.a.one=b.one;
 temp.a.two=b.two;
 i++;
 file2.Write(temp,input,1);
}
file.Close();
file2.Close();

1.txt - > 2.txt 암호화.
단순하게 텍스트정도는 뭔지 모르게 암호화할 수 있다.
바이너리도 간단하지만-_-; 암호화방법을 모르면 못풀겠고...
이올린에 북마크하기(0) 이올린에 추천하기(0)
2006/09/12 18:00 2006/09/12 18:00
─ tag  ,
openclose