Program for decrypting graphic files in C.
-
Hello, Quick prerequisite: I'm graphic designer and I have no idea about programing. Long story short I want to modify some graphic files but they are encrypted. I already have the code in C for decrypting them but I have no idea how to make it into working program. Also I have no idea about C language syntax so I'm not sure if I need to modify this code so I can show the program files I need to decrypt. I would be very grateful if someone could help me with this.
#include int main (int argc, char **argv)
{
FILE *inp, *outp;
int i;
char sig[] = "CF10", *ptr;if (argc != 3) { printf ("usage: decode \[input\] \[output\]\\n"); return -1; } inp = fopen (argv\[1\], "rb"); if (inp == NULL) { printf ("bad input file '%s'\\n", argv\[1\]); return -2; } ptr = sig; while (\*ptr) { i = fgetc (inp); if (\*ptr != i) { printf ("input file sig is not 'CF10'\\n"); return -2; } ptr++; } outp = fopen (argv\[2\], "wb"); if (outp == NULL) { printf ("bad output file '%s'\\n", argv\[1\]); return -2; } do { i = fgetc(inp); if (i != EOF) fputc (i ^ 0x8d, outp); } while (i != EOF); fclose (inp); fclose (outp); printf ("all done. bye bye\\n"); return 0;
}
-
Hello, Quick prerequisite: I'm graphic designer and I have no idea about programing. Long story short I want to modify some graphic files but they are encrypted. I already have the code in C for decrypting them but I have no idea how to make it into working program. Also I have no idea about C language syntax so I'm not sure if I need to modify this code so I can show the program files I need to decrypt. I would be very grateful if someone could help me with this.
#include int main (int argc, char **argv)
{
FILE *inp, *outp;
int i;
char sig[] = "CF10", *ptr;if (argc != 3) { printf ("usage: decode \[input\] \[output\]\\n"); return -1; } inp = fopen (argv\[1\], "rb"); if (inp == NULL) { printf ("bad input file '%s'\\n", argv\[1\]); return -2; } ptr = sig; while (\*ptr) { i = fgetc (inp); if (\*ptr != i) { printf ("input file sig is not 'CF10'\\n"); return -2; } ptr++; } outp = fopen (argv\[2\], "wb"); if (outp == NULL) { printf ("bad output file '%s'\\n", argv\[1\]); return -2; } do { i = fgetc(inp); if (i != EOF) fputc (i ^ 0x8d, outp); } while (i != EOF); fclose (inp); fclose (outp); printf ("all done. bye bye\\n"); return 0;
}
What development environment will you be using? Visual Studio?
The difficult we do right away... ...the impossible takes slightly longer.
-
What development environment will you be using? Visual Studio?
The difficult we do right away... ...the impossible takes slightly longer.
To be honest I have no preferences and I can be flexible. I doubt I'll use C again in my life. I have acces to Visual Studio but isn't it only for Visual C++, C$ and VB?
-
To be honest I have no preferences and I can be flexible. I doubt I'll use C again in my life. I have acces to Visual Studio but isn't it only for Visual C++, C$ and VB?
Well you'll have to choose one before someone can help you make a program. C code will compile in a C++ environment, so Visual C++ is OK.
The difficult we do right away... ...the impossible takes slightly longer.
-
Well you'll have to choose one before someone can help you make a program. C code will compile in a C++ environment, so Visual C++ is OK.
The difficult we do right away... ...the impossible takes slightly longer.
Makes total sense. Let's make it Visual Studio Express 2013 for Desktop to be precise then.
-
Well you'll have to choose one before someone can help you make a program. C code will compile in a C++ environment, so Visual C++ is OK.
The difficult we do right away... ...the impossible takes slightly longer.
Ok I figured out the easy part (how to compile C code in Visual Studio). But now there are two problems left: a) When I try to compile the code from my first post i get this error: "
Error 1 error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
EDIT: Ok I've dealt with this one by adding _CRT_SECURE_NO_WARNINGS to Preprocessor Definitions! b) When I deal with the bug above how to modify code so I can "show" the program which files I want to decrypt?
-
Ok I figured out the easy part (how to compile C code in Visual Studio). But now there are two problems left: a) When I try to compile the code from my first post i get this error: "
Error 1 error C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
EDIT: Ok I've dealt with this one by adding _CRT_SECURE_NO_WARNINGS to Preprocessor Definitions! b) When I deal with the bug above how to modify code so I can "show" the program which files I want to decrypt?
It looks like the code is written to accept the names of the files to decrypt on the command line. So you might invoke the program by entering "program /file_to_decrypt.txt", or something like that.
The difficult we do right away... ...the impossible takes slightly longer.
-
It looks like the code is written to accept the names of the files to decrypt on the command line. So you might invoke the program by entering "program /file_to_decrypt.txt", or something like that.
The difficult we do right away... ...the impossible takes slightly longer.
Yup I did exactly that. Topic can be closed. Thx for your help!
-
Yup I did exactly that. Topic can be closed. Thx for your help!
Glad you got it working. :)
The difficult we do right away... ...the impossible takes slightly longer.
-
Glad you got it working. :)
The difficult we do right away... ...the impossible takes slightly longer.
I have one last question about the software. How should I modify the code so instead of decrypting the files I can encypt them again using the same "CF10" signature. Thanks in advance.
-
I have one last question about the software. How should I modify the code so instead of decrypting the files I can encypt them again using the same "CF10" signature. Thanks in advance.
That would not be a simple change. You'd have to rewrite the whole thing.
The difficult we do right away... ...the impossible takes slightly longer.