Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Please,I need a data encryption scheme for encrypting data before saving them to file.

There is this application I am working on in which I need to save sensitive security information held in a buffer to file. However, I wish to encrypt the content of the buffer before saving to file and to de-encrypt the content on reading from file. This I expect will make it meaningless for any unauthorised person opening the file. Is there a way I can get such an encryption scheme?
Posted

You should use a symmetric encryption algorithm (like aes or twofish) that uses the same key (password) to encrypt/decrypt the data. Crypto++[^] is a very popular library, an I also recommend LibTomCrypt[^] that has very nice clean source even for learning purposes.
 
Share this answer
 
v2
You can do this using Data Protection API (in Windows).

See CryptProtectData() API in MSDN
 
Share this answer
 
You could read this article[^] which teaches about the Win32 cryptography API.
 
Share this answer
 
I have an article on encryption using Crypto++:

Encryption and compression, native and managed[^]

The sample encrypts a file using MFC but the library itself doesn't use MFC.

It includes compression and base 64 tranformation (if you need to copy paste the data).
 
Share this answer
 

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