Png SafeGuard/Compression/Scrambler?

Discussion in 'Mac Programming' started by Gandolfmatt, Mar 9, 2010.

  1. Gandolfmatt macrumors member

    Joined:
    Jul 18, 2008
    #1
    Hey guys, I'm making a game and I'd like to keep my graphics safe so others wouldn't be able to use them. Is there a way I could do this by a compressed format or possibly a formula to scramble and descramble the pictures?


    Thanks,
    -Gan
     
  2. jtara macrumors 65816

    Joined:
    Mar 23, 2009
    #2
    PNG is already a compressed format. You're unlikely to compress it much more if at all, and, of course, a compressed format doesn't protect the images anyway, except perhaps through "security by obscurity" if you use a compression format that nobody else knows about...


    Um, you mean an encryption algorithm? Sure, pick one.

    However, assuming you are going to display the graphics to the user - you ARE going to display the graphics to the user, right? I mean, that's most typically the purpose of graphics, I'm just sayin.... there's no point in it.

    The user can just snap a screen shot to the camera roll (top button and home button together) and they've got your graphics in a PNG file.

    So, this is a problem not to be concerned about, because it can't be fixed. Sorry. Next non-issue!

    (Edit: I wasn't paying attention to what forum I was in. This is MAC programming, not iPhone programming. No matter. Users can still take screen shots from your running game, just not using "the top button and the home button"...)
     
  3. Gandolfmatt thread starter macrumors member

    Joined:
    Jul 18, 2008
    #3
    I'm thinking of scrambling them then have the game descramble when it uses them.
    Of course these graphics are tiles and would be extremely tough to steal by taking screen shots. Especially with moving characters and such on the screen.

    So would you guys have any idea for a way to achieve this code-wise?


    Thanks,
    -Gan
    P.S. I'm not sure how to directly access individual pixels of an NSImage.
     
  4. kainjow Moderator emeritus

    kainjow

    Joined:
    Jun 15, 2000
    #4
    One way would be to scramble each file individually. Another would be to put all the files together (for example a zip), then scramble that file. Either way you'll want to write a script/command line tool to do this, and then write the corresponding code to read the files.

    This may be of help (just one way to go about encryption):
    http://iphonedevelopment.blogspot.com/2009/02/strong-encryption-for-cocoa-cocoa-touch.html

    Personally, I wouldn't worry about it until you're about to ship your product. Even then, if someone wants to gain access to your resources, they'll figure a way. For example they could write a plugin that loads with your app and grabs the images the same way you do, using your code, bypassing the encryption altogether. And that's not really that hard with tools like SIMBL, class-dump, nm, gdb, etc.
     
  5. Gandolfmatt thread starter macrumors member

    Joined:
    Jul 18, 2008
    #5
    Wait, so after I decrypt my png files they can copy it from the ram the decrypted pngs are stored at?


    -Gan
     
  6. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #6
    Yes, that's one way.

    Another way is to find the decryption key in your code, then decrypt your png files offline. And there are any number of ways of finding the key.
     
  7. Gandolfmatt thread starter macrumors member

    Joined:
    Jul 18, 2008
    #7
    Hmmm, well I don't know why someone would want to go through all that trouble so this is my idea.
    I separate the png into rows and columns. I move each column up or down a certain amount of pixels. Then I do the same on rows. Thus it makes a scrambled png. To use it I just do the same process backwards.
    Sound good? If so how can I do such a thing with an NSImage?


    -Gan
     
  8. chown33 macrumors 604

    Joined:
    Aug 9, 2009
    #8
    To steal your graphics, as you originally stated. Why would they do that? I have no idea. It's your assumption that the graphics are worth stealing, no one else's.

    You can invent all the seemingly clever scrambling you want, and someone with enough time and desire can still work around it. Since you seem determined to do this, despite recommendations against it from people who seem to know more about it, you should at least pick an approach within your current skills.

    You're proposing a simple graphics transformation, not even a significant cryptographic approach. It seems like all the information you need would be in the documentation for NSImage or NSImageRep.
     
  9. Gandolfmatt thread starter macrumors member

    Joined:
    Jul 18, 2008
    #9
    Well, I've learned from experience.
    It tiles are easily accessible, people will take them for their own use in their own games. If they aren't easily accessible then you're in the clear because I doubt a professional would like to steal a small or even large game's tiles.
    Ever use RpgXp? People will use whatever tiles they can find. I'm just trying to find a good way to keep my custom tiles out of circulation among beginning game makers who can only script mediocrely.

    Scrambling process doesn't have to be crazily complex, but just something that people won't be able to guess. Like move row 1 down 13 pixel, row 2 down 2 pixels, row 3 up 8 pixels, ect... Then repeat for columns. Makes the image looks like colored t.v. static.

    I'll look through the docs for code to get and set individual pixels though if any of you have already figured out the solution, please post. :)


    Thanks,
    -Gan
     

Share This Page