-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 9cf4fec
Showing
10 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
GCC = gcc | ||
CFLAGS = -g -Wall -Wshadow | ||
|
||
duckbits: duck.o | ||
$(GCC) $(CFLAGS) duck.o -o duckbits | ||
|
||
duck.o: duck.c | ||
$(GCC) $(CFLAGS) -c duck.c | ||
|
||
bitwise_op.o: bitwise_op.c | ||
$(GCC) $(CFLAGS) -c bitwise_op.c | ||
|
||
sample: | ||
make duckbits | ||
./duckbits |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Duckbits | ||
Duckbits flips bit according to the sequence calculated by the encryption key user entered. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
#include "bitwise_op.h" | ||
|
||
int getBitFromByte(int maskposition, unsigned char byte){ | ||
unsigned char mask = 0x80; | ||
switch(maskposition){ | ||
case 1: | ||
mask = 0x80; | ||
break; | ||
case 2: | ||
mask = 0x40; | ||
break; | ||
case 3: | ||
mask = 0x20; | ||
break; | ||
case 4: | ||
mask = 0x10; | ||
break; | ||
case 5: | ||
mask = 0x08; | ||
break; | ||
case 6: | ||
mask = 0x04; | ||
break; | ||
case 7: | ||
mask = 0x02; | ||
break; | ||
case 8: | ||
mask = 0x01; | ||
break; | ||
} | ||
|
||
return ((byte & mask) != 0); | ||
} | ||
|
||
unsigned char FillBit(unsigned char Bucket, int bitToFill, int offset){ | ||
//Position: LSB ...MSB 7..0 | ||
int absoffset = (offset - 8); | ||
if(absoffset < 0) absoffset *= -1; | ||
Bucket |= (bitToFill << absoffset); | ||
return Bucket; | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef BITWISEOP_H | ||
|
||
int getBitFromByte(int maskposition, unsigned char byte); | ||
unsigned char FillBit(unsigned char Bucket, int bitToFill, int offset); | ||
|
||
#endif |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
#include <stdio.h> | ||
#include "bitwise_op.c" | ||
#include <stdio.h> | ||
#include <string.h> | ||
|
||
FILE * OpenFile(char FileName[], char mode[]); | ||
void Duckfile(FILE * fptr_in, FILE * fptr_out); | ||
|
||
FILE * OpenFile(char FileName[], char mode[]){ | ||
FILE *myfile = NULL; | ||
myfile = fopen(FileName,mode); | ||
|
||
return myfile; | ||
} | ||
|
||
int main(int argc, const char * argv[]) | ||
{ | ||
|
||
// scanf("%d"); | ||
|
||
FILE * fptr_in = OpenFile("Breaking.Bad.S05E12.720p.HDTV.x264-EVOLVE.mkv", "rb"); | ||
FILE * fptr_out = OpenFile("Breaking.Bad.S05E12.720p.HDTV.x264-EVOLVE.ducked", "wb"); | ||
|
||
Duckfile(fptr_in,fptr_out); | ||
|
||
return 0; | ||
} | ||
|
||
void Duckfile(FILE * fptr_in, FILE * fptr_out){ | ||
char duck_key[64]; | ||
printf("Duckbits TWO-WAY ducking algorithm uses a 64 bytes key to secure your file using the low level DUCKMAN algorithm. Please enter the Ducking-Key (DK) you wish to use for this ducking: "); | ||
scanf("%s",duck_key); | ||
|
||
int bytecount = 0; | ||
unsigned int block; | ||
unsigned char byte_ducked; | ||
|
||
while(block != EOF){ | ||
// byte_buffer = 0x00; | ||
byte_ducked = 0x00; | ||
|
||
block = fgetc(fptr_in); | ||
if(block == EOF){ | ||
break; | ||
} | ||
|
||
int i = 0; | ||
for(i = 1; i <= 8; i++){ | ||
bytecount += 1; | ||
int writebit = getBitFromByte(i, block); | ||
// byte_buffer = FillBit(byte_buffer, writebit, i); | ||
int DUCKTHIS = i % 2; | ||
|
||
if(DUCKTHIS){ | ||
//If the Ducking-Key tells you to duck this bit, do it | ||
byte_ducked = FillBit(byte_ducked, (writebit == 0 ? 1 : 0), i); | ||
}else{ | ||
//Leave intact otherwise | ||
byte_ducked = FillBit(byte_ducked, writebit, i); | ||
} | ||
|
||
} | ||
// printf("\nOriginal: %d (%c)\n",byte_buffer,byte_buffer); | ||
// printf("Ducked: %d (%c)\n",byte_ducked,byte_ducked); | ||
|
||
fputc(byte_ducked,fptr_out); | ||
} | ||
|
||
printf("\n"); | ||
|
||
printf("%d Bytes Can Fly!\n", bytecount); | ||
} |
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
���ߋ����ߑ�����ߐ�ߚ�������ߌ�����������߈������ߖ�ߍ�����������ߋ���ߑ�����ߛ������ߙ���ߋ��ߜ����ߏ���������ߞ߈������ߚ����ߏ��������ߋ��ߙ�������ߙ���ߜ����������߶�ߋ���ߜ����ߋ��ߚ����ߖ���������י������߈���ߝ�ߌ��ߙ��ߋ��ߌ���������ߚ�����ߌ���ߐ�ߜ����ߖ�߅����ߋ��ߙ�������ߍ������߅���ߞ��ߋ��ߚ����ߖ��������ߍ������ߊ����������������ߖ�ߞ�ߊ�������ߖ�������ߋ����� |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
The total number of elements successfully written is returned. | ||
If this number differs from the count parameter, a writing error prevented the function from completing. In this case, the error indicator (ferror) will be set for the stream. | ||
If either size or count is zero, the function returns zero and the error indicator remains unchanged. | ||
size_t is an unsigned integral type. |