Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Program for decrypting graphic files in C.

Program for decrypting graphic files in C.

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
11 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T TheDefenestrator

    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;
    

    }

    Richard Andrew x64R Offline
    Richard Andrew x64R Offline
    Richard Andrew x64
    wrote on last edited by
    #2

    What development environment will you be using? Visual Studio?

    The difficult we do right away... ...the impossible takes slightly longer.

    T 1 Reply Last reply
    0
    • Richard Andrew x64R Richard Andrew x64

      What development environment will you be using? Visual Studio?

      The difficult we do right away... ...the impossible takes slightly longer.

      T Offline
      T Offline
      TheDefenestrator
      wrote on last edited by
      #3

      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?

      Richard Andrew x64R 1 Reply Last reply
      0
      • T TheDefenestrator

        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?

        Richard Andrew x64R Offline
        Richard Andrew x64R Offline
        Richard Andrew x64
        wrote on last edited by
        #4

        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.

        T 2 Replies Last reply
        0
        • Richard Andrew x64R Richard Andrew x64

          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.

          T Offline
          T Offline
          TheDefenestrator
          wrote on last edited by
          #5

          Makes total sense. Let's make it Visual Studio Express 2013 for Desktop to be precise then.

          1 Reply Last reply
          0
          • Richard Andrew x64R Richard Andrew x64

            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.

            T Offline
            T Offline
            TheDefenestrator
            wrote on last edited by
            #6

            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?

            Richard Andrew x64R 1 Reply Last reply
            0
            • T TheDefenestrator

              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?

              Richard Andrew x64R Offline
              Richard Andrew x64R Offline
              Richard Andrew x64
              wrote on last edited by
              #7

              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.

              T 1 Reply Last reply
              0
              • Richard Andrew x64R Richard Andrew x64

                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.

                T Offline
                T Offline
                TheDefenestrator
                wrote on last edited by
                #8

                Yup I did exactly that. Topic can be closed. Thx for your help!

                Richard Andrew x64R 1 Reply Last reply
                0
                • T TheDefenestrator

                  Yup I did exactly that. Topic can be closed. Thx for your help!

                  Richard Andrew x64R Offline
                  Richard Andrew x64R Offline
                  Richard Andrew x64
                  wrote on last edited by
                  #9

                  Glad you got it working. :)

                  The difficult we do right away... ...the impossible takes slightly longer.

                  T 1 Reply Last reply
                  0
                  • Richard Andrew x64R Richard Andrew x64

                    Glad you got it working. :)

                    The difficult we do right away... ...the impossible takes slightly longer.

                    T Offline
                    T Offline
                    TheDefenestrator
                    wrote on last edited by
                    #10

                    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.

                    Richard Andrew x64R 1 Reply Last reply
                    0
                    • T TheDefenestrator

                      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.

                      Richard Andrew x64R Offline
                      Richard Andrew x64R Offline
                      Richard Andrew x64
                      wrote on last edited by
                      #11

                      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.

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups