C and C# file encryption method and particular solution -
i have small system on windows 7 os consists of 2 application (c , c# applications) , database text or binary file in fact.
c application read database, c# application read , write. defend database file outward impacts.
i tend use public-key cryptography method, rsa example. offer better 1 method or better particular solution. suggest need open source, commercial-friendly licensed libraries (like openssl) c , c# languages. own implementation choice too.
upd: change both applications code , want encrypt entire file.
you should use standard symmetric encryption. ms has provided article subject. http://support.microsoft.com/kb/307010/en-us. writing own encryption method results insecure , errorness algorithm.
example of initialization using password , salt:
var enc = new rijndaelmanaged(); rfc2898derivebytes key = new rfc2898derivebytes(pw, encoding.ascii.getbytes(salt)); enc.key = key.getbytes(encryption.keysize / 8); enc.iv = key.getbytes(encryption.blocksize / 8); enc.padding = paddingmode.pkcs7;
in case, have got problem create , store password , salt. salt can stored along file (e.g. first 16 bytes or may choose filename) , must not secured. password entered user.
if data bound windows account may prefere using data protection api because user not need perform password input. nice example ist provided @ data protection api
you may interested in first answer of so discussion
Comments
Post a Comment