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#
  4. Custom file type

Custom file type

Scheduled Pinned Locked Moved C#
helpquestionlearning
20 Posts 9 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.
  • E Etienne_123

    Hi I have a friend who's a photographer and he's looking for a way to burn DVDs for his customers with the photos on. He wants to include both low resolution and high resolution photos on the disc, but he doesn't want his customers to be able to access the high res photos. They must bring the disc to him if they want any photos printed. What I suggested to him was to create an application that will allow him to save the photos in a different file format, and only he must be able to open these photos with this application. I quickly fiddled with some code and saved an image in a different file format, but then of course one can still open these files by simply using the "Open With" dialog. I know there must be more to it than simply just saving it in a different file format. Maybe using some form of Serializer? Any help in the right direction would be appreciated.

    C Offline
    C Offline
    Chris Trelawny Ross
    wrote on last edited by
    #3

    A simple trick might be to write some binary value - an indicator byte/int/long plus some indicator of the type of image that the rest of the file contains (e.g. 0xD1CEDBEE + ".JPG" for a total of 8 bytes, or 12 if you save the string as multibyte characters) - at the beginning of a new file, then stream the binary of the high-res image immediately following that byte. Save the file with a custom extension 'xxx.hires' or somesuch. The presence of the custom header will prevent any standard software from being able to process the file as a recognized image file. The custom app can validate the header, then create a .Net Image object from the remainder of the content in the file. Specifying the embedded image type in the header allows for future implementations that use other file formats (which may not necessarily be images at all). If you don't like having ".JPG" in readable characters, XOR each byte of the string with some binary value, say 0x53. Just XOR them again when reading them back, to get back to the original characters. You should probably also include a length field describing the embedded string, for flexibility, instead of assuming that it is always going to be 4 characters; I would also include a version # "just in case".

    1 Reply Last reply
    0
    • E Etienne_123

      Hi I have a friend who's a photographer and he's looking for a way to burn DVDs for his customers with the photos on. He wants to include both low resolution and high resolution photos on the disc, but he doesn't want his customers to be able to access the high res photos. They must bring the disc to him if they want any photos printed. What I suggested to him was to create an application that will allow him to save the photos in a different file format, and only he must be able to open these photos with this application. I quickly fiddled with some code and saved an image in a different file format, but then of course one can still open these files by simply using the "Open With" dialog. I know there must be more to it than simply just saving it in a different file format. Maybe using some form of Serializer? Any help in the right direction would be appreciated.

      OriginalGriffO Offline
      OriginalGriffO Offline
      OriginalGriff
      wrote on last edited by
      #4

      I'm sorry - that was a little blunt. My fault! I was going to say: Encrypt the files - use the small file filename and some random-but-fixed data mixed together as the key and use the .NET Encryption services. Save the file with the extension ".encrypt" appended to the ".jpg" or whatever bit, and you are good to go.

      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      E 1 Reply Last reply
      0
      • E Etienne_123

        Hi I have a friend who's a photographer and he's looking for a way to burn DVDs for his customers with the photos on. He wants to include both low resolution and high resolution photos on the disc, but he doesn't want his customers to be able to access the high res photos. They must bring the disc to him if they want any photos printed. What I suggested to him was to create an application that will allow him to save the photos in a different file format, and only he must be able to open these photos with this application. I quickly fiddled with some code and saved an image in a different file format, but then of course one can still open these files by simply using the "Open With" dialog. I know there must be more to it than simply just saving it in a different file format. Maybe using some form of Serializer? Any help in the right direction would be appreciated.

        K Offline
        K Offline
        Kubajzz
        wrote on last edited by
        #5

        What you are looking for is called encryption. The photos can be in the original format (.jpg or whatever), but the files should be encrypted using a good algorithm and a strong password to keep the data protected. You can either use some ready-to-use encryption software, or create your own program from scratch... If you decide to write your own program, see the System.Security.Cryptography namespace (there are high-quality encryption algortihms ready for you in the .NET library). There are also several articles about encryption here at CodeProject.

        1 Reply Last reply
        0
        • E Etienne_123

          Hi I have a friend who's a photographer and he's looking for a way to burn DVDs for his customers with the photos on. He wants to include both low resolution and high resolution photos on the disc, but he doesn't want his customers to be able to access the high res photos. They must bring the disc to him if they want any photos printed. What I suggested to him was to create an application that will allow him to save the photos in a different file format, and only he must be able to open these photos with this application. I quickly fiddled with some code and saved an image in a different file format, but then of course one can still open these files by simply using the "Open With" dialog. I know there must be more to it than simply just saving it in a different file format. Maybe using some form of Serializer? Any help in the right direction would be appreciated.

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #6

          put the hi-res files inside a password-protected ZIP; or encrypt them. :)

          Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

          Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

          Y 1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Encryption

            Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

            E Offline
            E Offline
            Etienne_123
            wrote on last edited by
            #7

            Never thought of encryption :) I did a quick search and came up with something that will work fine: File Encryption and Decryption in C#[^] Thanks guys

            1 Reply Last reply
            0
            • OriginalGriffO OriginalGriff

              I'm sorry - that was a little blunt. My fault! I was going to say: Encrypt the files - use the small file filename and some random-but-fixed data mixed together as the key and use the .NET Encryption services. Save the file with the extension ".encrypt" appended to the ".jpg" or whatever bit, and you are good to go.

              Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

              E Offline
              E Offline
              Etienne_123
              wrote on last edited by
              #8

              Which encryption algorithm would you recommend though? There are numerous included in .NET. The one I came across that works fine is "RijndaelManaged".

              OriginalGriffO 1 Reply Last reply
              0
              • E Etienne_123

                Hi I have a friend who's a photographer and he's looking for a way to burn DVDs for his customers with the photos on. He wants to include both low resolution and high resolution photos on the disc, but he doesn't want his customers to be able to access the high res photos. They must bring the disc to him if they want any photos printed. What I suggested to him was to create an application that will allow him to save the photos in a different file format, and only he must be able to open these photos with this application. I quickly fiddled with some code and saved an image in a different file format, but then of course one can still open these files by simply using the "Open With" dialog. I know there must be more to it than simply just saving it in a different file format. Maybe using some form of Serializer? Any help in the right direction would be appreciated.

                A Offline
                A Offline
                AspDotNetDev
                wrote on last edited by
                #9

                An alternate idea... Save the high resolution images to a database on your computer. Associate a unique key to each photo, or just create a single key for an entire batch of images. Include that key(s) on the DVD with the low resolution images. When the customer gives you the DVD, use that key to lookup the high resolution pictures on your computer. The "database", "key", and "computer" can be anything you like. For example, one configuration might be:

                Database: SQL Server
                Key: GUID
                Computer: PC

                Alternate cofiguration:

                Database: Excel File
                Key: Customer name and date the photos were put on the DVD
                Computer: DVD's with the key written on them

                No need to put the data in the user's hands.

                [Forum Guidelines]

                1 Reply Last reply
                0
                • E Etienne_123

                  Hi I have a friend who's a photographer and he's looking for a way to burn DVDs for his customers with the photos on. He wants to include both low resolution and high resolution photos on the disc, but he doesn't want his customers to be able to access the high res photos. They must bring the disc to him if they want any photos printed. What I suggested to him was to create an application that will allow him to save the photos in a different file format, and only he must be able to open these photos with this application. I quickly fiddled with some code and saved an image in a different file format, but then of course one can still open these files by simply using the "Open With" dialog. I know there must be more to it than simply just saving it in a different file format. Maybe using some form of Serializer? Any help in the right direction would be appreciated.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #10

                  Store the Picture in Sqlite DataBase and lock it with password

                  I know nothing , I know nothing ...

                  1 Reply Last reply
                  0
                  • E Etienne_123

                    Which encryption algorithm would you recommend though? There are numerous included in .NET. The one I came across that works fine is "RijndaelManaged".

                    OriginalGriffO Offline
                    OriginalGriffO Offline
                    OriginalGriff
                    wrote on last edited by
                    #11

                    For your situation I wouldn't go for anything too complex - All you want is something that bollixes up the simple user from getting his high-res pics for free, I assume? Follow this[^] and you won't go too far wrong - it's pretty easy to follow, but without your key it's pretty much unbreakable. It won't stop the FBI or the mafia, but then I hope your pictures wouldn't interest either! :laugh:

                    Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                    "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                    E 1 Reply Last reply
                    0
                    • E Etienne_123

                      Hi I have a friend who's a photographer and he's looking for a way to burn DVDs for his customers with the photos on. He wants to include both low resolution and high resolution photos on the disc, but he doesn't want his customers to be able to access the high res photos. They must bring the disc to him if they want any photos printed. What I suggested to him was to create an application that will allow him to save the photos in a different file format, and only he must be able to open these photos with this application. I quickly fiddled with some code and saved an image in a different file format, but then of course one can still open these files by simply using the "Open With" dialog. I know there must be more to it than simply just saving it in a different file format. Maybe using some form of Serializer? Any help in the right direction would be appreciated.

                      N Offline
                      N Offline
                      Not Active
                      wrote on last edited by
                      #12

                      The best way to keep secrets is to not have any. If they must come to him to have images printed anyway, why even store them on the disc? Keeping them does put the onus on the photographer for storage but I'd be surprised if doesn't already have a backup plan. It also gives the option for a client to call/email an order and have them sent.


                      I know the language. I've read a book. - _Madmatt

                      E 1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        For your situation I wouldn't go for anything too complex - All you want is something that bollixes up the simple user from getting his high-res pics for free, I assume? Follow this[^] and you won't go too far wrong - it's pretty easy to follow, but without your key it's pretty much unbreakable. It won't stop the FBI or the mafia, but then I hope your pictures wouldn't interest either! :laugh:

                        Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                        E Offline
                        E Offline
                        Etienne_123
                        wrote on last edited by
                        #13

                        Yes you're completely right. While we're on the subject, would it be possible to compile all of these photos into one single encrypted package which can then only be opened by the application? That would be ideal, but if I have to store all the files separately then that's not a train smash either.

                        OriginalGriffO 1 Reply Last reply
                        0
                        • N Not Active

                          The best way to keep secrets is to not have any. If they must come to him to have images printed anyway, why even store them on the disc? Keeping them does put the onus on the photographer for storage but I'd be surprised if doesn't already have a backup plan. It also gives the option for a client to call/email an order and have them sent.


                          I know the language. I've read a book. - _Madmatt

                          E Offline
                          E Offline
                          Etienne_123
                          wrote on last edited by
                          #14

                          I asked the same question :-D The only reason I can think of is that he does not want to keep backups of all his photos.

                          1 Reply Last reply
                          0
                          • L Luc Pattyn

                            put the hi-res files inside a password-protected ZIP; or encrypt them. :)

                            Luc Pattyn [Forum Guidelines] [Why QA sucks] [My Articles] Nil Volentibus Arduum

                            Please use <PRE> tags for code snippets, they preserve indentation, and improve readability.

                            Y Offline
                            Y Offline
                            Yusuf
                            wrote on last edited by
                            #15

                            Luc Pattyn wrote:

                            a password-protected ZIP

                            very easy to copy and crack :thumbsdown:

                            Luc Pattyn wrote:

                            encrypt them

                            better alternative. :thumbsup:

                            Yusuf May I help you?

                            A 1 Reply Last reply
                            0
                            • E Etienne_123

                              Hi I have a friend who's a photographer and he's looking for a way to burn DVDs for his customers with the photos on. He wants to include both low resolution and high resolution photos on the disc, but he doesn't want his customers to be able to access the high res photos. They must bring the disc to him if they want any photos printed. What I suggested to him was to create an application that will allow him to save the photos in a different file format, and only he must be able to open these photos with this application. I quickly fiddled with some code and saved an image in a different file format, but then of course one can still open these files by simply using the "Open With" dialog. I know there must be more to it than simply just saving it in a different file format. Maybe using some form of Serializer? Any help in the right direction would be appreciated.

                              Y Offline
                              Y Offline
                              Yusuf
                              wrote on last edited by
                              #16

                              Another Idea. Leave the hi-res images as hi-res so the customer can open them and see the difference. But put distinct watermark, so when printed it does not look good.

                              Yusuf May I help you?

                              1 Reply Last reply
                              0
                              • Y Yusuf

                                Luc Pattyn wrote:

                                a password-protected ZIP

                                very easy to copy and crack :thumbsdown:

                                Luc Pattyn wrote:

                                encrypt them

                                better alternative. :thumbsup:

                                Yusuf May I help you?

                                A Offline
                                A Offline
                                AspDotNetDev
                                wrote on last edited by
                                #17

                                You do realize that password-protecting a ZIP file is a form of encryption, right?

                                [Forum Guidelines]

                                Y 1 Reply Last reply
                                0
                                • A AspDotNetDev

                                  You do realize that password-protecting a ZIP file is a form of encryption, right?

                                  [Forum Guidelines]

                                  Y Offline
                                  Y Offline
                                  Yusuf
                                  wrote on last edited by
                                  #18

                                  One of the weakest types of encryption, huh! :^)

                                  Yusuf May I help you?

                                  A 1 Reply Last reply
                                  0
                                  • Y Yusuf

                                    One of the weakest types of encryption, huh! :^)

                                    Yusuf May I help you?

                                    A Offline
                                    A Offline
                                    AspDotNetDev
                                    wrote on last edited by
                                    #19

                                    I don't know, is 256-bit AES encryption weak?

                                    [Forum Guidelines]

                                    1 Reply Last reply
                                    0
                                    • E Etienne_123

                                      Yes you're completely right. While we're on the subject, would it be possible to compile all of these photos into one single encrypted package which can then only be opened by the application? That would be ideal, but if I have to store all the files separately then that's not a train smash either.

                                      OriginalGriffO Offline
                                      OriginalGriffO Offline
                                      OriginalGriff
                                      wrote on last edited by
                                      #20

                                      Yes - the encryption doesn't care what the content is. I would suggest either a simple directory structure, or just a length prefix/filename combination to each file so you can extract them from the decrypted stream.

                                      Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.

                                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                                      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                                      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