공용체를 잠깐 봐보고, 암호화를 해보았다.
간단하게 각 1바이트의 4비트를 2개로 쪼개어, 앞뒤만 섞어준다.
|||||||| -> ||||||||
1.txt - > 2.txt 암호화.
단순하게 텍스트정도는 뭔지 모르게 암호화할 수 있다.
바이너리도 간단하지만-_-; 암호화방법을 모르면 못풀겠고...
간단하게 각 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();
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 암호화.
단순하게 텍스트정도는 뭔지 모르게 암호화할 수 있다.
바이너리도 간단하지만-_-; 암호화방법을 모르면 못풀겠고...


rss