• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
3
Question by Rabwin · Dec 08, 2011 at 03:49 PM · encryption

Aes encryption

I want to use AES encryption provider to encrypt data. I've got the correct directives I need like System.Security.Cryptography and I can use other providers without problems (I have tried DES and RSA).

I get this error

error CS0246: The type or namespace name `AesCryptoServiceProvider' could not be found. Are you missing a using directive or an assembly reference?

when trying to declare this object:

 AesCryptoServiceProvider AES = new AesCryptoServiceProvider();

I understand I should have probably kept this question to somewhere like stack overflow but I don't think they could help since this seems to be a Unity specific problem?

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

6 Replies

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Rabwin · Dec 08, 2011 at 04:36 PM

I was able to use System.Security.Cryptography.RijndaelManaged which I believe is an implementation of AES or something like that, good enough for me as I'm just playing around with this stuff for savegame data and things of the sort.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
2

Answer by Statement · Dec 08, 2011 at 04:32 PM

Since Unity uses Mono, all features might not be implemented.

  • See Cryptography on mono-project for more details.

Maybe you can find a third party implementation?

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Rabwin · Dec 08, 2011 at 04:35 PM 0
Share

I don't think I will be able to use third party implementations without doing some major work or using unity pro if I want to use plugins to invoke .dlls which I'd like to avoid. Thanks for the help though, I wish they would update mono.

avatar image Bunny83 · Feb 01, 2012 at 03:55 AM 1
Share

No, it's no problem (even in the indy version of Unity) to use any managed dlls. Just drop them as assets in your project. NOT in the plugins directory. Every "normal" assembly can be included in a Unity project. Even in webbuilds, but keep in $$anonymous$$d that the $$anonymous$$ono interpreter of the webplayer has a lot security restrictions. If your third party assembly tries to use any restricted API (like System.IO) it will throw an exception.

You may also check the $$anonymous$$onoCompatibility page which shows all namespaces / classes / methods that are supported for the different platforms. (watch out, this page is huge! It takes some time to load ;) )

If you look up "AesCryptoServiceProvider" you'll see that it should be available for usual Standalone builds, but check your build settings. If you use the .NET subset it won't be available.

avatar image
1

Answer by col000r · Jul 29, 2014 at 03:21 PM

Have a look at this helper class: http://stackoverflow.com/a/17549863/3804618

Works beautifully in unity! Just add

using Common.Cryptography;

to your script and start calling AES.Encrypt and AES.Decrypt...

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by diekeure · Jan 19, 2012 at 03:34 PM

I have the same problem:

error CS0246: The type or namespace name `Aes' could not be found. Are you missing a using directive or an assembly reference?

But only in the webplayer and iOs, not for a standalone player. Any way to solve this?

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by bilal.du · Jan 31, 2012 at 07:53 PM

Hi every body, I had the same problem when I was trying to Encrypt String using AES (C#) and the solution was so simple you just need to upgrade your application Frame work from 2.0 to 3.5 at least and then you got every thing fine. I hope that help

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Bunny83 · Feb 01, 2012 at 04:08 AM 0
Share

That shouldn't be necessary. According to the compatibility page it's available on .NET 2.0.

See my comment on Statement's answer.

  • 1
  • 2
  • ›

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

If you’re new to Unity Answers, please check our User Guide to help you navigate through our website and refer to our FAQ for more information.

Before posting, make sure to check out our Knowledge Base for commonly asked Unity questions.

Check our Moderator Guidelines if you’re a new moderator and want to work together in an effort to improve Unity Answers and support our users.

Follow this Question

Answers Answers and Comments

11 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to use AES encryption ? 1 Answer

Simple HTTPS question 1 Answer

Does my app use Encryption? 0 Answers

Encrypted shader or Compiled shader for sharing with other unity3D developers 4 Answers

Why is there a loading bar that says decrypting package randomly showing up? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges