Click here to Skip to main content
15,907,492 members
Home / Discussions / C#
   

C#

 
GeneralCrystal Reports newcomer and Visual Studio Pin
Braulio Dez19-Feb-03 6:07
Braulio Dez19-Feb-03 6:07 
QuestionHow can I save GDI drawings on a form to jpg or gif Files Pin
mosessaur19-Feb-03 5:35
mosessaur19-Feb-03 5:35 
AnswerRe: How can I save GDI drawings on a form to jpg or gif Files Pin
Aboelkhair20-Feb-03 12:45
Aboelkhair20-Feb-03 12:45 
GeneralHelp Please: ComboBox Control in WinForm Datagrid Control Pin
DionChen19-Feb-03 5:08
DionChen19-Feb-03 5:08 
Generalc# and win CE Pin
Roger Alsing19-Feb-03 2:55
Roger Alsing19-Feb-03 2:55 
GeneralRe: c# and win CE Pin
Stephane Rodriguez.19-Feb-03 3:10
Stephane Rodriguez.19-Feb-03 3:10 
GeneralRe: c# and win CE Pin
Roger Alsing19-Feb-03 23:09
Roger Alsing19-Feb-03 23:09 
GeneralRe: c# and win CE Pin
Stephane Rodriguez.19-Feb-03 23:18
Stephane Rodriguez.19-Feb-03 23:18 
GeneralRe: c# and win CE Pin
sunnytyra7-Oct-09 17:52
sunnytyra7-Oct-09 17:52 
GeneralRe: c# and win CE Pin
TigerNinja_20-Feb-03 4:57
TigerNinja_20-Feb-03 4:57 
GeneralRe: c# and win CE Pin
Furty20-Feb-03 17:45
Furty20-Feb-03 17:45 
GeneralC# Call VC DLL Pin
aoyee19-Feb-03 1:31
aoyee19-Feb-03 1:31 
GeneralRe: C# Call VC DLL Pin
Stephane Rodriguez.19-Feb-03 3:00
Stephane Rodriguez.19-Feb-03 3:00 
GeneralRe: C# Call VC DLL Pin
Anonymous19-Feb-03 11:41
Anonymous19-Feb-03 11:41 
QuestionWhy xml line highlighted yellow in IDE? Pin
Member 9618-Feb-03 16:20
Member 9618-Feb-03 16:20 
AnswerRe: Why xml line highlighted yellow in IDE? Pin
Furty18-Feb-03 16:27
Furty18-Feb-03 16:27 
GeneralRe: Why xml line highlighted yellow in IDE? Pin
Member 9618-Feb-03 16:40
Member 9618-Feb-03 16:40 
GeneralRe: Why xml line highlighted yellow in IDE? Pin
Atul Kale19-Feb-03 7:19
Atul Kale19-Feb-03 7:19 
GeneralRe: Why xml line highlighted yellow in IDE? Pin
Member 9619-Feb-03 12:12
Member 9619-Feb-03 12:12 
GeneralRe: Why xml line highlighted yellow in IDE? Pin
David Stone19-Feb-03 12:02
sitebuilderDavid Stone19-Feb-03 12:02 
GeneralRe: Why xml line highlighted yellow in IDE? Pin
Member 9619-Feb-03 12:16
Member 9619-Feb-03 12:16 
Generalcryptography question Pin
jtmtv1818-Feb-03 14:23
jtmtv1818-Feb-03 14:23 
GeneralRe: cryptography question Pin
Furty18-Feb-03 16:09
Furty18-Feb-03 16:09 
The simplest way would be to have a fixed salt byte array of course, however the next easiest option would be to write the salt bytes to your filestream when encrypting, and read them back when decrypting.

Encryption:

FileStream fs = File.Create(filename);<br />
byte[] salt = new byte[16];<br />
RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();<br />
rng.GetBytes(salt);<br />
fs.Write(salt, 0, salt.Length)<br />
<br />
// PasswordDeriveBytes and do your encrypting..


Decryption:

FileStream fs = File.OpenRead(filename);<br />
byte[] salt = new byte[16];<br />
fs.Read(salt, 0, salt.Length)<br />
<br />
// PasswordDeriveBytes and do your decrypting..


While this is certainly not the best method of doing it, it will work fine. Ideally your salt bytes would also be encrypted, so as not to weaken the basic thing they're about. But then again, your IV should be unique and encrypted too, and you should be using a keyed checksum, and etc etc.. OK, I'll write an article and put together a wrapper for it all *when* I get a few hours free time.. For now this will get you by Smile | :)
GeneralRe: cryptography question Pin
jtmtv1818-Feb-03 16:57
jtmtv1818-Feb-03 16:57 
GeneralPassing various Controls by ref Pin
draco_iii18-Feb-03 10:56
draco_iii18-Feb-03 10:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.