AES-256 Encryption in c#

Hello,
I need an AES-256 encryption/decryption example and found one.  How would I know if this is 256 bit encryption?

https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.aes?view=netframework-4.7.2

Thank  you!
RadhaKrishnaKiJayaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Easy way to do this is to either call out to the openssl command line tool or use an openssl library binding.

If you call out to the openssl command line tool, your code will tend to work better across openssl releases, as a variety of errors seem to keep cropping up in c# bindings calling openssl libraries directly.
RadhaKrishnaKiJayaAuthor Commented:
Thank you David Favor,
I don't understand what you are saying.

Thank you!
Devin BeckerIdentity Management and SecurityCommented:
Radha,

On the page you linked, after the example, it says that the parameter KeySize can be assigned a Key Size, which will allow you to choose between 64, 128, or 256 Key Length. This is not show in the example, but it is possible.

EDIT: it looks like the KeySize is in bytes. which means you would uses a KeySize of 32bytes if you wanted 256Bit encryption.

Hope this helps,

Devin Becker
DevOps Associate @ EE
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

RadhaKrishnaKiJayaAuthor Commented:
Thank you Devin.  Do you have any example or sample code to show me?  Thank you!
Devin BeckerIdentity Management and SecurityCommented:
Radha,

Along with the link you had already posted, here is this information: https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.aesmanaged.keysize?view=netframework-4.7.2#System_Security_Cryptography_AesManaged_KeySize

EDIT: Also worth noting the difference between bytes and bits. 1 Byte = a combination of 8 bits. 8 bits = 1 byte. 32 bytes = 256 bits. Keep this in mind when writing out your code.

Hope this helps,

Devin Becker
DevOps Associate @ EE
Kyle AbrahamsSenior .Net DeveloperCommented:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
RadhaKrishnaKiJayaAuthor Commented:
Hello Kyle,
I was looking at a another thread where it is defined like this.

                  CCEncryption.m_Key = new byte[0x20];
                  CCEncryption.m_IV = new byte[0x10];

Any idea what does it mean?  What are the variables m_Key and m_IV?   Why are they declared byte[0x20] and byte[0x10]?

I know these are stupid questions.  But, I did not understand.

Thank you!
RadhaKrishnaKiJayaAuthor Commented:
Thank you guys for your help.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.