Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I need a way to encrypt and Decrypt a file of any extention with AES in C++.

The Requirements for my Project:

Encryption with AES256
Creating the AES Key from a Password the user enters

I am not very good at C++ becouse i have just previously started learning it.

It would be great if someone could help me here.

What I have tried:

I searched the Internet for 2 Hours now and i cant figure it out
Posted
Updated 25-Jun-21 21:28pm

See Cryptography API: Next Generation - Win32 apps | Microsoft Docs[^]. Encryption does not care what data it works on, so you can do it by treating all files as streams of bytes.
 
Share this answer
 
Comments
Marcel Waschnig 26-Jun-21 3:30am    
This is a very good answer thx.
Richard MacCutchan 26-Jun-21 3:42am    
Thanks. I have used this myself in a small scale application and it works well.
Any DES encryption code will handle data "of any extension" as all files are binary data, and a stream or array of binary data is all you need to load in order to encrypt it.

Text files are binary files that contain a "limited subset" of the binary byte phase space, or which apply a "layer" of interpretation to the binary data (for example UTF8 uses a multibyte encoding to get 16 bit data into 8 bit bytes).

So any code you use that encrypts and decrypts any file should work for every file.
Start with the official documentation for the environment your code will work in - a C++ CLI solution will use the .NET framework, while an MFC solution would be different - the relevant Microsoft help page will provide basic code samples which should work.
 
Share this answer
 
Comments
Marcel Waschnig 26-Jun-21 3:27am    
This is Good but i still dont know how to encrypt the file with AES

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900