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. Any File Encryption

Any File Encryption

Scheduled Pinned Locked Moved C / C++ / MFC
c++securitytutorialquestion
7 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.
  • G Offline
    G Offline
    Genius Am Not
    wrote on last edited by
    #1

    Im tryin to write a VC++ application to encrypt any file the user selects. I have done it for a binary file. But have no idea about how to do it if its a video or picture file. What do i do?:doh::confused:

    Jesus Loves Us Just the way we are! Invite Him into your life today!

    A 1 Reply Last reply
    0
    • G Genius Am Not

      Im tryin to write a VC++ application to encrypt any file the user selects. I have done it for a binary file. But have no idea about how to do it if its a video or picture file. What do i do?:doh::confused:

      Jesus Loves Us Just the way we are! Invite Him into your life today!

      A Offline
      A Offline
      Arman S
      wrote on last edited by
      #2

      No difference. Those files are binary too.

      -- ===== Arman

      G 1 Reply Last reply
      0
      • A Arman S

        No difference. Those files are binary too.

        -- ===== Arman

        G Offline
        G Offline
        Genius Am Not
        wrote on last edited by
        #3

        But then wat about loading the contents of the file to encrypt and stuff... do i do it the same way?? cuz i tried using the same method and the encrypted stuff is not the same as the source...:(

        Jesus Loves Us Just the way we are! Invite Him into your life today!

        A 1 Reply Last reply
        0
        • G Genius Am Not

          But then wat about loading the contents of the file to encrypt and stuff... do i do it the same way?? cuz i tried using the same method and the encrypted stuff is not the same as the source...:(

          Jesus Loves Us Just the way we are! Invite Him into your life today!

          A Offline
          A Offline
          Arman S
          wrote on last edited by
          #4

          Then what's the purpose of your encryption? What encryption method are you using?

          -- ===== Arman

          G 1 Reply Last reply
          0
          • A Arman S

            Then what's the purpose of your encryption? What encryption method are you using?

            -- ===== Arman

            G Offline
            G Offline
            Genius Am Not
            wrote on last edited by
            #5

            This is the code snippet for the original binary file encryption program. I just need to convert this so that it can accept any file. Im using the RIjnael class for the encryption and decryption. The purpose is to encrypt and decrypt any file using the same key. void CFileEnDecryptionDlg::Char2Hex(const unsigned char ch, char *szHex) { unsigned char byte[2]; byte[0] = ch/16; byte[1] = ch%16; for(int i=0; i<2; i++) { if(byte[i] >= 0 && byte[i] <= 9) szHex[i] = '0' + byte[i]; else szHex[i] = 'A' + byte[i] - 10; } szHex[2] = 0; } void CFileEnDecryptionDlg::Hex2Char(const char *szHex, unsigned char &rch) { rch = 0; for(int i=0; i<2; i++) { if(*(szHex + i) >='0' && *(szHex + i) <= '9') rch = (rch << 4) + (*(szHex + i) - '0'); else if(*(szHex + i) >='A' && *(szHex + i) <= 'F') rch = (rch << 4) + (*(szHex + i) - 'A' + 10); else break; } } void CFileEnDecryptionDlg::CharStr2HexStr(const char *pucCharStr, char *pszHexStr, int iSize) { int i; char szHex[3]; pszHexStr[0] = 0; for(i=0; iSetWindowText(""); // Get the window Text output->GetWindowText(key); input->GetWindowText(text); int flag = 0; if(key.GetLength()==0) { output->SetWindowText("1234567890123456"); msgbox->SetWindowText("Default Value of key used"); } if(text.GetLength() == 0){ input->SetWindowText("Scolis Technologies Pvt. Ltd."); output->GetWindowText(key); input->GetWindowText(text); flag = 1; } // Initilalize the object rijndael.MakeKey ((LPCTSTR)key); int length = text.GetLength(); if((text.GetLength() % 16) != 0) { // pad up the text while((text.GetLength() % 16) != 0) { text.Insert(length,'0'); length++; } if (flag == 0) msgbox->SetWindowText("Zero

            A 1 Reply Last reply
            0
            • G Genius Am Not

              This is the code snippet for the original binary file encryption program. I just need to convert this so that it can accept any file. Im using the RIjnael class for the encryption and decryption. The purpose is to encrypt and decrypt any file using the same key. void CFileEnDecryptionDlg::Char2Hex(const unsigned char ch, char *szHex) { unsigned char byte[2]; byte[0] = ch/16; byte[1] = ch%16; for(int i=0; i<2; i++) { if(byte[i] >= 0 && byte[i] <= 9) szHex[i] = '0' + byte[i]; else szHex[i] = 'A' + byte[i] - 10; } szHex[2] = 0; } void CFileEnDecryptionDlg::Hex2Char(const char *szHex, unsigned char &rch) { rch = 0; for(int i=0; i<2; i++) { if(*(szHex + i) >='0' && *(szHex + i) <= '9') rch = (rch << 4) + (*(szHex + i) - '0'); else if(*(szHex + i) >='A' && *(szHex + i) <= 'F') rch = (rch << 4) + (*(szHex + i) - 'A' + 10); else break; } } void CFileEnDecryptionDlg::CharStr2HexStr(const char *pucCharStr, char *pszHexStr, int iSize) { int i; char szHex[3]; pszHexStr[0] = 0; for(i=0; iSetWindowText(""); // Get the window Text output->GetWindowText(key); input->GetWindowText(text); int flag = 0; if(key.GetLength()==0) { output->SetWindowText("1234567890123456"); msgbox->SetWindowText("Default Value of key used"); } if(text.GetLength() == 0){ input->SetWindowText("Scolis Technologies Pvt. Ltd."); output->GetWindowText(key); input->GetWindowText(text); flag = 1; } // Initilalize the object rijndael.MakeKey ((LPCTSTR)key); int length = text.GetLength(); if((text.GetLength() % 16) != 0) { // pad up the text while((text.GetLength() % 16) != 0) { text.Insert(length,'0'); length++; } if (flag == 0) msgbox->SetWindowText("Zero

              A Offline
              A Offline
              Arman S
              wrote on last edited by
              #6

              Ok, if your purpose is solely encrypt/decrypt, then this code will do. Only do open the file in binary mode, read bytes from there and pass them to your enryption algorythm. If after encryption and a corresponding decryption you cannot get what you had before, than your algorythms are wrong; no matter you have used video, image or other types of files.

              -- ===== Arman

              G 1 Reply Last reply
              0
              • A Arman S

                Ok, if your purpose is solely encrypt/decrypt, then this code will do. Only do open the file in binary mode, read bytes from there and pass them to your enryption algorythm. If after encryption and a corresponding decryption you cannot get what you had before, than your algorythms are wrong; no matter you have used video, image or other types of files.

                -- ===== Arman

                G Offline
                G Offline
                Genius Am Not
                wrote on last edited by
                #7

                hey thanks duude it worked

                Jesus Loves Us Just the way we are! Invite Him into your life today!

                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