Search Unity

Encrypt data in Resources on Build

Discussion in 'Scripting' started by Yorgi, May 30, 2015.

  1. Yorgi

    Yorgi

    Joined:
    Apr 18, 2014
    Posts:
    9
    Hello. I have a question about can i encrypt my XML documents on build. They are placed in ..\Assets\Resources\... of course i can encrypt them before build, but it's uncomfortable because maybe later I'll have to change them. And my question is: is it possible to keep data human readable in resources and encrypt on build?
     
  2. laxbrookes

    laxbrookes

    Joined:
    Jan 9, 2015
    Posts:
    235
    Why do you need to encrypt them?

    Assets used become serialized when the project is built anyway. I'm unsure what you are asking here.
     
  3. Yorgi

    Yorgi

    Joined:
    Apr 18, 2014
    Posts:
    9
    well after build i found my xml documents readable, maybe i did something wrong
     
  4. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    How about you encrypt them, store them in resources and then when you load them in your script decrypt them? Still possible to decrypt but it always will be...
     
  5. Yorgi

    Yorgi

    Joined:
    Apr 18, 2014
    Posts:
    9
    i was thinking about that, but i thought there must be another solution beside decrypt/encrypt always then i need to change anything in xml files
     
  6. Jamster

    Jamster

    Joined:
    Apr 28, 2012
    Posts:
    1,102
    I think you can write editor scripts that execute when a build is made so you could perhaps encrypt it from there?
     
  7. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    There is no Resources folder in a build anyway, so don't worry about it.

    --Eric
     
  8. Yorgi

    Yorgi

    Joined:
    Apr 18, 2014
    Posts:
    9
    yep, but there is "resources.assets" file in root directory of "BuildName_Data", which contains xml files and after build they are human readable
     
  9. laxbrookes

    laxbrookes

    Joined:
    Jan 9, 2015
    Posts:
    235
    They are only viewable in development builds if I remember rightly. Otherwise that "_data" folder will not exist.
     
  10. Yorgi

    Yorgi

    Joined:
    Apr 18, 2014
    Posts:
    9
    nope i did the common build. I have the personal license by the way
     
  11. Yorgi

    Yorgi

    Joined:
    Apr 18, 2014
    Posts:
    9
    it's a good idea, but i never developed the editor script, so it would be bit hard