c# - how to store mysql connection data safely? -
this question has answer here:
- asp.net connectionstring in secure way 7 answers
i'd begin new project , 1 of first problems i've figured out security of mysql connection data.
i want know if it's possible configure software choose database server; reason it's necessary store connection informations (user, password, databasename) in kind of file (xml, bin, ...) thats not safe , viewed due lack of encryption.
is there easy way protect these sensitive informations or have write own encryption mechanism ?
in case have write own one, there guideline right?
no, don't need write own encryption it, .net have encryption.
simply use rijndael (aes) - encryption.
import namespace: using system.security.cryptography;
then use class: rijndael class
and take @ thread: how generate rijndael key , iv using passphrase? use encryption properly/safely.
example:
private static byte[] encryptstring(byte[] cleartext, byte[] key, byte[] iv) { memorystream ms = new memorystream(); rijndael alg = rijndael.create(); alg.key = key; //look @ linked stackoverflow-thread alg.iv = iv; // on how create key , iv cryptostream cs = new cryptostream(ms, alg.createencryptor(), cryptostreammode.write); cs.write(cleartext, 0, cleartext.length); cs.close(); byte[] encrypteddata = ms.toarray(); return encrypteddata; }
Comments
Post a Comment