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

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

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

will this be free?or will be in assetstore later?

@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.

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.

@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.

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?

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

@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.

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

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

Good, is this service free as well or i need to pay something to store my secret key?

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.

Thanks again runningbird…
I will try it to see if I can use it or not !?!

6R

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.

AES is something I’m looking into adding into uCrypt.

Thanks for the input ImogenPoot :slight_smile:

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.

@runningbird

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

This should work for any file type.

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?