CodeVerge.Net Beta


   Explore    Item Entry    Members      Register  Login  
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML

Free Download:




Zone: > NEWSGROUP > Asp.Net Forum > starter_kits_and_source_projects.dotnetnuke.getting_started Tags:
Item Type: NewsGroup Date Entered: 2/3/2004 2:31:07 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 0 Views: 109 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
4 Items, 1 Pages 1 |< << Go >> >|
vetter1
Asp.Net User
Using Password and Salt with SHA12/3/2004 2:31:07 AM

0/0

I'm trying to change my dnn installation to use a sha1 encryption with a salt to make my database more secure per my client's request. I was trying to implement something like http://www.aspheute.com/english/20040105.asp but in vb. I've tried to add all the functions to the security.vb component. I'm having trouble with password method

Expression is not an array or a method, and cannot have an argument list. Dim pwd As String = Password(Password, SaltID)

Also having trouble with pwd.ComputeSaltedHash() is not a member of 'String'.


Has anyone implemented something like this? If not, would someone be willing to help me troubleshoot my errors.

I have most of the other code and sp modifications made. Just need to be able to initalize my password with salt.
I would like to be able to contribute back to the project by defining all of the code needed and contributing back for others to use.

Thanks,
vetter1
vetter1
Asp.Net User
Re: Using Password and Salt with SHA12/5/2004 3:00:47 AM

0/0

ok, got past that but am getting a new error,

Specified cast is not valid.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[InvalidCastException: Specified cast is not valid.]
DotNetNuke.Register.RegisterBtn_Click(Object sender, EventArgs E) +1619
System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) +83
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1277


Any suggestions?

vetter1
Asp.Net User
Re: Using Password and Salt with SHA12/8/2004 5:13:33 PM

0/0

I've redone this using the following in the security.vb file

'http://www.obviex.com/samples/hash.aspx

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' SAMPLE: Hashing data with salt using MD5 and several SHA algorithms.
'
' To run this sample, create a new Visual Basic.NET project using the Console
' Application template and replace the contents of the Module1.vb file with
' the code below.
'
' THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
' EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
' WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
'
' Copyright (C) 2003. Obviex(TM). All rights reserved.
'
'Imports System
'Imports System.Text
'Imports System.Security.Cryptography



' <SUMMARY>
' This class generates and compares hashes using MD5, SHA1, SHA256, SHA384,
' and SHA512 hashing algorithms. Before computing a hash, it appends a
' randomly generated salt to the plain text, and stores this salt appended
' to the result. To verify another plain text value against the given hash,
' this class will retrieve the salt value from the hash string and use it
' when computing a new hash of the plain text. Appending a salt value to
' the hash may not be the most efficient approach, so when using hashes in
' a real-life application, you may choose to store them separately. You may
' also opt to keep results as byte arrays instead of converting them into
' base64-encoded strings.
' </SUMMARY>
'Public Class SimpleHash

' <SUMMARY>
' Generates a hash for the given plain text value and returns a
' base64-encoded result. Before the hash is computed, a random salt
' is generated and appended to the plain text. This salt is stored at
' the end of the hash value, so it can be used later for hash
' verification.
' </SUMMARY>
' <PARAM name="plainText">
' Plaintext value to be hashed. The function does not check whether
' this parameter is null.
' </PARAM>
' < name="hashAlgorithm">
' Name of the hash algorithm. Allowed values are: "MD5", "SHA1",
' "SHA256", "SHA384", and "SHA512" (if any other value is specified
' MD5 hashing algorithm will be used). This value is case-insensitive.
' </PARAM>
' < name="saltBytes">
' Salt bytes. This parameter can be null, in which case a random salt
' value will be generated.
' </PARAM>
' <RETURNS>
' Hash value formatted as a base64-encoded string.
' </RETURNS>
Public Shared Function ComputeHash(ByVal plainText As String, ByVal hashAlgorithm As String, ByVal saltBytes() As Byte) As String

' If salt is not specified, generate it on the fly.
If (saltBytes Is Nothing) Then

' Define min and max salt sizes.
Dim minSaltSize As Integer
Dim maxSaltSize As Integer

minSaltSize = 4
maxSaltSize = 8

' Generate a random number for the size of the salt.
Dim random As Random
random = New Random()

Dim saltSize As Integer
saltSize = random.Next(minSaltSize, maxSaltSize)

' Allocate a byte array, which will hold the salt.
saltBytes = New Byte(saltSize - 1){}

' Initialize a random number generator.
Dim rng As RNGCryptoServiceProvider
rng = New RNGCryptoServiceProvider()

' Fill the salt with cryptographically strong byte values.
rng.GetNonZeroBytes(saltBytes)
End If

' Convert plain text into a byte array.
Dim plainTextBytes As Byte()
plainTextBytes = Encoding.UTF8.GetBytes(plainText)

' Allocate array, which will hold plain text and salt.
Dim plainTextWithSaltBytes() As Byte = New Byte(plainTextBytes.Length + saltBytes.Length - 1){}

' Copy plain text bytes into resulting array.
Dim I As Integer
For I = 0 To plainTextBytes.Length - 1
plainTextWithSaltBytes(I) = plainTextBytes(I)
Next I

' Append salt bytes to the resulting array.
For I = 0 To saltBytes.Length - 1
plainTextWithSaltBytes(plainTextBytes.Length + I) = saltBytes(I)
Next I

' Because we support multiple hashing algorithms, we must define
' hash object as a common (abstract) base class. We will specify the
' actual hashing algorithm class later during object creation.
Dim hash As HashAlgorithm

' Make sure hashing algorithm name is specified.
If (hashAlgorithm Is Nothing) Then
hashAlgorithm = ""
End If

' Initialize appropriate hashing algorithm class.
Select hashAlgorithm.ToUpper()

Case "SHA1"
hash = New SHA1Managed()

Case "SHA256"
hash = New SHA256Managed()

Case "SHA384"
hash = New SHA384Managed()

Case "SHA512"
hash = New SHA512Managed()

Case Else
hash = New MD5CryptoServiceProvider()

End Select

' Compute hash value of our plain text with appended salt.
Dim hashBytes As Byte()
hashBytes = hash.ComputeHash(plainTextWithSaltBytes)

' Create array which will hold hash and original salt bytes.
Dim hashWithSaltBytes() As Byte = New Byte(hashBytes.Length + saltBytes.Length - 1) {}

' Copy hash bytes into resulting array.
For I = 0 To hashBytes.Length - 1
hashWithSaltBytes(I) = hashBytes(I)
Next I

' Append salt bytes to the result.
For I = 0 To saltBytes.Length - 1
hashWithSaltBytes(hashBytes.Length + I) = saltBytes(I)
Next I

' Convert result into a base64-encoded string.
Dim hashString As String
hashString = Convert.ToBase64String(hashWithSaltBytes)

' Return the result.
Return hashString

End Function

'************************************************

And I'm referrencing it in the register module as

UserId = objUser.AddUser(PortalId, txtFirstName.Text, txtLastName.Text, Address1.Unit, Address1.Street, Address1.City, Address1.Region, Address1.Postal, Address1.Country, Address1.Telephone, txtEmail.Text, txtUsername.Text, objSecurity.ComputeHash(txtPassword.Text, "SHA512", Nothing), IIf(_portalSettings.UserRegistration = 1, CStr(False), CStr(True)), UserId)

However, whenever I look at the passwords they are only 12 characters in length which is incorrect. What am I doing wrong?

vetter1
vetter1
Asp.Net User
Re: Using Password and Salt with SHA12/9/2004 12:28:04 AM

0/0

got it, inproper resource referrence.

Thanks!
4 Items, 1 Pages 1 |< << Go >> >|


Free Download:

Books:
Information Security Management Handbook Authors: Harold F. Tipton, Micki Krause, Pages: 578, Published: 2005
Oracle Database 11g: New Features for DBAs and Developers Authors: Sam R. Alapati, Charles Kim, Pages: 602, Published: 2007
Handbook of Information Security: Threats, Vulnerabilities, Prevention, Detection, and Management Authors: Hossein Bidgoli, Pages: 3366, Published: 2006
The Hacker's Handbook: The Strategy Behind Breaking Into and Defending Networks Authors: J. Burke Hansen, Susan Elizabeth Young, Susan Young, Dave Aitel, Pages: 860, Published: 2003
PHP Solutions, Dynamic Web Design Made Easy: Dynamic Web Design Made Easy Authors: David Powers, SpringerLink (Online service, Pages: 0, Published: 2006
Pro PHP Security Authors: Chris Snyder, Michael Southwell, Pages: 500, Published: 2005
The Internet Encyclopedia: P - Z Authors: Hossein Bidgoli, Pages: 976, Published: 2004
Hardening Network Security: Network Security Authors: John Mallery, Jason Zann, Patrick Kelly, Wesley Noonan, Paul Love, Eric S. Seagren, Rob Kraft, Mark O'Neill, Pages: 608, Published: 2005
Advanced Rails Authors: Brad Ediger, Pages: 357, Published: 2007

Web:
secure hashes in PHP using salt « Patrick’s development blog Feb 12, 2008 ... if (stored_password == sha1($salt.$password)) { print “You are logged in!”; }. I can write a more practical example of using salts someday. ...
PHP MD5 + Salt + sha1 + base64_encde Encryption tutorial tips ... PHP MD5 + Salt + sha1 + base64_encde Encryption tutorial tips tricks and demos. ... $salt_pass = md5($password.$salt); ?> If you don't like the salt + MD5 ...
PHP Security Consortium: Password Hashing Note: Using MySQL's password() function in your own applications isn't recommended ... The resulting string consists of the salt followed by the SHA-1 hash ...
How To: Hash Data with Salt (C#/VB.NET) NET using MD5, SHA1, SHA256, SHA384, and SHA512 algoritnms. ... COMPARING PASSWORD HASHES MD5 (good): True MD5 (bad) : False SHA1 (good): True SHA1 (bad) ...
Re: Change Auth component will solve hash without salt? When checking password, Auth always hashing using sha1 combine with >> > > security.salt. >> > > It's makes different value compare with my password in ...
Salt your passwords | Tim Jansson password_hash = Digest::SHA1.hexdigest(”–#{salt}–#{password}–”) ... Instead of using the user’s “signup_date”, I used the “password_lastupdated” field in my ...
Change Auth component will solve hash without salt? - CakePHP ... password in your DB "pure" SHA1? > If you're using the Auth component all the way, it will hash the > password including Salt when the user registers, ...
Coverage Data #if NET_2_0 public PasswordDeriveBytes (byte[] password, byte[] salt) { Prepare (password, salt, "SHA1", 100); } public PasswordDeriveBytes (byte[] password ...
Using SHA1 to hash passwords in 1.1 not playing nice in 2.0 - ASP ... using System.Security.Cryptography; using System.Text; public static string HashPassword(Guid salt, string password) { SHA1 hash = SHA1. ...
PHP: sha1 - Manual If your still using sha1, here is a function that will hopefully help a little. .... You are much much better off adding a variable salt to passwords before ...




Search This Site:










iis home directory

unable to delete and re-add portal in 3.0.11

free skin...

datasets vs datatables vs dataviews

menubreakcssclass

visual source safe

error while trying to run project: unable to start debugging on the web server.click help for more information.

no data in site log

find auto incrementing id

deploying a web service

unknown code

absolute positioning

forms authentication with 3 different login forms (roles)

how to launch excel application

skin panes alignment

did a upgrade 2.12 to 3.0.10

ftb-freetextbox ???? help me !!!!!!

simple understand problem

split content pane for side by side layout

problem installing web controls

update scans

unable to establish secure connection with the server

new to asp.net: access denied problem

after creating user, its logs u out. how to stop this?

ftb3 - image gallery - languages

invert of background color

string.empty or ""

css selector ,inline sytle success ,link style failed,why

scheduler - "run on server" setting

how do i add events to a customcontrol?

 
All Times Are GMT