Click here to Skip to main content
16,005,181 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: what is the problem with this code Pin
Paul Conrad13-Jul-07 4:32
professionalPaul Conrad13-Jul-07 4:32 
QuestionWhy can't i catch parameter Pin
boyindie12-Jul-07 23:10
boyindie12-Jul-07 23:10 
AnswerRe: Why can't i catch parameter Pin
Guffa12-Jul-07 23:40
Guffa12-Jul-07 23:40 
GeneralRe: Why can't i catch parameter Pin
boyindie12-Jul-07 23:47
boyindie12-Jul-07 23:47 
GeneralRe: Why can't i catch parameter Pin
Dave Kreskowiak13-Jul-07 2:45
mveDave Kreskowiak13-Jul-07 2:45 
GeneralRe: Why can't i catch parameter Pin
boyindie13-Jul-07 2:56
boyindie13-Jul-07 2:56 
GeneralRe: Why can't i catch parameter Pin
boyindie13-Jul-07 3:05
boyindie13-Jul-07 3:05 
GeneralRe: Why can't i catch parameter Pin
Dave Kreskowiak13-Jul-07 5:51
mveDave Kreskowiak13-Jul-07 5:51 
Hmmm...I can't really see anything wrong with it. I've done similar stuff in the past, but instead of using UTF8 encoding to convert the salt to a string, I converted it to a Base64 string and added that you the password.

I've always generated the salt in a seperate function, generated the salted password hash in another...
Private Function GenerateSalt(ByVal size As Integer) As String
    ' The drop dead minumum useful salt size is 5 bytes, and
    ' a max of 12 would generate a string of 8 to 20 Base64 characters.
    size = Math.Min(Math.Max(5, size), 12)
 
    Dim rng As New RNGCryptoServiceProvider()
    Dim buffer(size) As Byte
    rng.GetBytes(buffer)
 
    Return Convert.ToBase64String(buffer)
End Function
 
Private Function GenerateSaltedPasswordHash(ByVal password As String, ByVal salt As String) As String
    ' This section is GREATLY simplified.  I normally do something MUCH more
    ' wicked to combine the password and salt, and hash it.  Of course, I'm not saying what...
    Dim saltedPassword As String = password & salt
    Dim SHA As New SHA512Managed
    Dim buffer() As Byte = Encoding.UTF8.GetBytes(saltedPassword)
 
    Return Convert.ToBase64String(SHA.ComputeHash(buffer))
End Function

Why do I use Base64 so much?? Easy. The return values are suitable for storage on/in ANY medium. XML files, any database, any file, ...

This version of the function would generate a password hash string about 80 to 100 characters long. Your milage may vary. This length of password may or may NOT be acceptable to you. Consider the situation where you may have 60,000,000 users. That's a password column containing 6GB of data, not counting the salt storage, or any other user data.


A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


AnswerRe: Why can't i catch parameter Pin
Guffa13-Jul-07 6:03
Guffa13-Jul-07 6:03 
GeneralRe: Why can't i catch parameter Pin
boyindie16-Jul-07 4:33
boyindie16-Jul-07 4:33 
GeneralRe: Why can't i catch parameter Pin
Guffa16-Jul-07 12:15
Guffa16-Jul-07 12:15 
GeneralRe: Why can't i catch parameter Pin
boyindie16-Jul-07 12:18
boyindie16-Jul-07 12:18 
QuestionMy own equalizer Pin
bala_kathir12-Jul-07 21:20
bala_kathir12-Jul-07 21:20 
AnswerRe: My own equalizer Pin
Dave Kreskowiak13-Jul-07 2:41
mveDave Kreskowiak13-Jul-07 2:41 
Questiondisable back and forward button Pin
Ashish Kumar Vyas12-Jul-07 18:49
Ashish Kumar Vyas12-Jul-07 18:49 
AnswerRe: disable back and forward button Pin
Sathesh Sakthivel12-Jul-07 19:18
Sathesh Sakthivel12-Jul-07 19:18 
GeneralRe: disable back and forward button Pin
Dave Kreskowiak13-Jul-07 2:38
mveDave Kreskowiak13-Jul-07 2:38 
AnswerRe: disable back and forward button Pin
RepliCrux12-Jul-07 20:06
RepliCrux12-Jul-07 20:06 
GeneralRe: disable back and forward button Pin
Ashish Kumar Vyas12-Jul-07 23:37
Ashish Kumar Vyas12-Jul-07 23:37 
GeneralRe: disable back and forward button Pin
Vasudevan Deepak Kumar13-Jul-07 0:06
Vasudevan Deepak Kumar13-Jul-07 0:06 
Questionerror when commiting the row to the original data store(urgent) Pin
cutequencher12-Jul-07 16:49
cutequencher12-Jul-07 16:49 
AnswerRe: error when commiting the row to the original data store(urgent) Pin
Christian Graus12-Jul-07 17:09
protectorChristian Graus12-Jul-07 17:09 
GeneralRe: error when commiting the row to the original data store(urgent) Pin
cutequencher12-Jul-07 17:50
cutequencher12-Jul-07 17:50 
QuestionToggle Button in ToolStrip Pin
MadmanWoo12-Jul-07 13:13
MadmanWoo12-Jul-07 13:13 
AnswerRe: Toggle Button in ToolStrip Pin
Paul Conrad13-Jul-07 12:25
professionalPaul Conrad13-Jul-07 12:25 

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.