Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

uCrypt: encrypt and decrypt your assets, files, etc from local or web storage.

Discussion in 'Made With Unity' started by runningbird, Jul 31, 2012.

  1. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    As requested from a few members I've created a small library I called uCrypt that does just what the name implies it encrypts and decrypts files.

    If you want to secure your files and have them encrypted in your game so that no one can use your assets without your "Secret Key" then uCrypt is for you



    uCrypt has 3 small functions that will secure your files.

    ***Demo Included***
    uCrypt Package

    Version 0.0.2:
    Included in this release is the Unity script version / Javascript.
    As well as the bug fix for the "internal compiler error"

    All you have to do is:
    • Include the uCrypt dll in your project
    • Attach the uCryptDemo script to a game object
    • Change the file paths to your files
    and you are ready to go.

    The package contents


    The demo txt file


    The encrypted file


    The un-encrypted file
     
    Last edited: Jul 31, 2012
  2. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    It's very interesting...
    For example I can encrypt a script, a texture, and so on...
    But one file at once ???
    (Sorry, I don't know anything in encrypting !)

    6R
     
  3. liverolA

    liverolA

    Joined:
    Feb 10, 2009
    Posts:
    347
    will this be free?or will be in assetstore later?
     
  4. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    @p6r yes for now it is only one file at a time and it doesn't matter on the file type that you encrypt.
    I will be adding more features soon.
    To do multiple files you can just loop through them I'll add an example for that.

    Encryption is good so that no one can open the file without knowing your encryption algorithm which is taken care of by uCrypt also they need to know you secret key.


    @liverolA yes it's free now you can download the demo and it's all included.
    I will create a zip file for it as well so you can just include the script file and dll soon.

    Upcoming features encrypt variables so if you need to send them to a database, server, client etc it's encrypted.

    Also I will have a service that can store your key for you in two different security scenarios.
    1. we store your key so you don't have it locally included in your game anywhere.
    2. we store 2 parts of the key so that you have double the security.
     
  5. LeWyRaWr

    LeWyRaWr

    Joined:
    Jul 6, 2012
    Posts:
    12
    Awesome! Just what I need!

    Can you include a Unityscript version for those who don't have experience in C#?

    I'm also getting an internal compiler error when importing the package to a new project.
     
    Last edited: Jul 31, 2012
  6. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    @LeWyRaWr sure thing I'll include it as soon as I can. Check back later tonight.

    I'll check out the compiler issue might be the .Net version I had selected.
     
  7. TheEnigmist

    TheEnigmist

    Joined:
    Jun 10, 2012
    Posts:
    51
    I'm a noob in encrypting. If i share an encrypted file and some1 else will download your demo, he can decrypt it and do whatever he wants, or i'm wrong?
     
  8. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Thanks a lot runningbird,

    +1 for Unityscript...

    People say on this forum it's very easy to extract datas from unity.3d web files. With your system they can't do that anymore ??? But we can play the game online without problem !?! Right ???

    6R
     
  9. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    @TheEnigmist
    They could only decrypt the file if they had your secret key.

    I will be creating a web service for any who use uCrypt to store your "SecretKey" for you.
    This way you don't have to store the key in your project.

    @p6r I will make a demo of this to show how you can do this so no one can steal your files / assets anymore.

    It seems that there is a bit of interest in the security of project files etc so I'll put more features in to help.
     
  10. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    GREAT !

    Yes... Like other ones I was very surprised to learn it's so easy to extract datas.
    Unity3D allows us to create web demos but it's not fair if people can extract and steal all your work.

    Thanks again runningbird,

    6R
     
  11. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    New release!!! Version 0.0.2:
    Included in this release is the Unity script version / Javascript.
    As well as the bug fix for the "internal compiler error" - I recompiled it to .Net 3.5
     
  12. TheEnigmist

    TheEnigmist

    Joined:
    Jun 10, 2012
    Posts:
    51
    Good, is this service free as well or i need to pay something to store my secret key?
     
  13. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    The service will cost $10 / key this will be a one time cost only to help cover any hosting / bandwith used serving your secret key.

    Of course there will be a trial period of 14 days to test the service out for your apps etc.
     
  14. p6r

    p6r

    Joined:
    Nov 6, 2010
    Posts:
    1,158
    Thanks again runningbird...
    I will try it to see if I can use it or not !?!

    6R
     
  15. ImogenPoot

    ImogenPoot

    Joined:
    Jul 2, 2012
    Posts:
    214
    He hopefully can't... Otherwise this would be totally broken ^^

    But anyway all of you should be aware that this provides nothing but the most basic form of security. Encryption like that is practically useless for anything serious. I bet most of you are not working on such mega duper assets others are craving to have. If you don't then you don't need to encrypt, if you do, encryption won't be enough LOL...

    There is one thing you actually can do. Obfuscate your entire project with a good obfuscation tool and sophistically hide an encryption key or better many of those in there, using a source code impl of AES or something similar, so that no one can intercept the key easily with an API hooker... This will raise the bar to a level where someone needs to be REALLY dedicated to get your assets. But still, it is not impossible by any means and it will be done by someone if there is a need...

    One thing, all I said above is only useful if you have a LARGE C# codebase (making obfuscation viable and giving you a lot of space to effectively hide information). Otherwise you are completely lost. Then there is not even the slightest chance that you can protect your assets against anyone but the most dumb hijacker.
     
    Last edited: Aug 2, 2012
  16. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    AES is something I'm looking into adding into uCrypt.

    Thanks for the input ImogenPoot :)
     
  17. I am da bawss

    I am da bawss

    Joined:
    Jun 2, 2011
    Posts:
    2,574
    Very interesting!

    I agree with ImogenPoot, its impossible to stop people from dissecting your project and stealing your work when it is in public domain. When you package your game, you must also package the key with it, and hide the key in there. Even storing the keys elsewhere have vulnerabiilities - it become easier actually because the hackers just have to monitor the packets going in and out and isolate the key packet.
     
    Last edited: Aug 3, 2012
  18. viv710

    viv710

    Joined:
    Jul 29, 2016
    Posts:
    8
    @runningbird

    I'm new to Unity and C#. Can i encrypt and decrypt image files like jpg,png etc...
     
  19. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    This should work for any file type.
     
  20. crudeMe

    crudeMe

    Joined:
    Jul 8, 2015
    Posts:
    92
    heyo, pretty useful stuff. But I'm not quite sure where to begin. DecryptFile() is not returning anything, it writes decrypted file back to hard drive. How exactly I can use ucrypt?
     
  21. StephenALEGROS

    StephenALEGROS

    Joined:
    Oct 2, 2017
    Posts:
    3
    Im kinda confused...
    Can you add a step by step tutorial??
     
  22. StephenALEGROS

    StephenALEGROS

    Joined:
    Oct 2, 2017
    Posts:
    3
    The steps above is confusing for me.
     
  23. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    Ucrypt was create to encrypt and decrypt your files that was it.
    I will put together a step by step tutorial in the next week.
     
  24. StephenALEGROS

    StephenALEGROS

    Joined:
    Oct 2, 2017
    Posts:
    3
    Can I combine this with the obfuscator?
     
  25. unity_aRxVO5khrOgayA

    unity_aRxVO5khrOgayA

    Joined:
    Apr 25, 2018
    Posts:
    1
    Include the uCrypt dll in your project ? How ?
     
  26. biswadeep_sarkar

    biswadeep_sarkar

    Joined:
    Dec 27, 2018
    Posts:
    1
    @runningbird Hi, the encryption/decryption is not working for .jpg file. I am doing the same as in the demo.

    Capture.JPG Capture2.JPG
     
  27. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    How does this protect my assets from copying? The player build must include secret key and decryption algorythm in order for game to function, must not it?
     
  28. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    It doesn't and that is a good point to note about the secret key etc. This asset was created back in 2012 and I haven't updated it forever :(. There are probably much better ways of doing this nowadays and I'll look and see if I can update it eventually.
     
  29. runningbird

    runningbird

    Joined:
    Sep 3, 2009
    Posts:
    382
    biswadeep_sarkar likes this.
  30. palex-nx

    palex-nx

    Joined:
    Jul 23, 2018
    Posts:
    1,748
    The only effective protection for your work is being the best in what you doing so noone may copy you fast and good enough to compete. Encrypting files in player build on user machine is useless because in order to process those files (sounds/text/graphics/whatever) and show to user program needs to decrypt them. Wich effectively means providing means to decrypt and steal your "secret" along with encrypted data. It's like a putting a house key under front door mat so everyone knows it is there.