File tree Expand file tree Collapse file tree 3 files changed +33
-2
lines changed
Expand file tree Collapse file tree 3 files changed +33
-2
lines changed Original file line number Diff line number Diff line change 1+ using System ;
2+ using System . Security . Cryptography ;
3+
4+ namespace PBKDF2Hash
5+ {
6+ private static byte [ ] GenerateSalt ( )
7+ {
8+ var csprng = new RNGCryptoServiceProvider ( ) ;
9+ var salt = new byte [ 32 ] ;
10+ csprng . GetBytes ( salt ) ;
11+ return salt ;
12+ }
13+
14+ public static ( byte [ ] hash , byte [ ] salt ) pbkdf2hash ( string password )
15+ {
16+
17+ string password = "passwd" ;
18+ byte [ ] salt = GenerateSalt ( ) ; //warning shouldnt be random salts - change when you try and decrypt no?
19+ int iterations = 100000 ;
20+ byte [ ] hashValue ;
21+ using ( var pbkdf2 = new Rfc2898DeriveBytes ( password , salt , iterations ) )
22+ {
23+ hashValue = pbkdf2 . GetBytes ( 32 ) ;
24+ }
25+ return ( hashValue , salt ) ;
26+ }
27+ }
Original file line number Diff line number Diff line change 1- # EncryptionApp
1+ # EncryptionApp
2+
3+ ## Documentation:
4+
5+
6+ ## To do:
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments