Print Page | Close Window

Encrypting a Password Before It is Added

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: ASP.NET Discussion
Forum Description: Discussion and chat on ASP.NET related topics.
URL: https://forums.webwiz.net/forum_posts.asp?TID=15015
Printed Date: 29 March 2026 at 12:52pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Encrypting a Password Before It is Added
Posted By: Misty
Subject: Encrypting a Password Before It is Added
Date Posted: 10 May 2005 at 3:15pm
I am trying to encrypt a password value before it is being added to the database. Can someone please help me with this?
 
I am currently getting the following error message:
 
Compiler Error Message: BC30451: Name 'EncryptIt' is not declared.

Source Error:

Line 215:                         objDataRow("Password") = System.DBNull.Value 
Line 216:                 else 
Line 217:                         objDataRow("Password") = EncryptIt(Password, strENCRYPTION_TYPE)  
Line 218:                 end if 
Here's some of my code:
 
dim Password as String
Password = txtPassword.Text
code that has an error:  'Set string values
if Password = "" then
objDataRow("Password") = System.DBNull.Value
else
objDataRow("Password") = EncryptIt(Password, strENCRYPTION_TYPE)
end if



Replies:
Posted By: Mart
Date Posted: 10 May 2005 at 4:06pm
Well do you have a function called encrypt it? And if so have you imported the namespace it is in? I.e. if its in the namespace MyEncryption.CryptoStuff you need to put a

<%@ Import NameSpace="MyEncryption.CryptoStuff" %>

or

Imports MyEncryption.CryptoStuff

or

using MyEncryption.CryptoStuff;

where applicable


Posted By: michael
Date Posted: 10 May 2005 at 4:07pm
Where is your EncryptIt Function located?
 
Try something like


Dim password as String = txtPassword.Text
 
If password="" or password = String.Empty THEN
   objDataRow("Password") = System.DBNull.Value
Else
  objDataRow("Password") = EncryptIt(Password, strEncryption_Type)
End If
 
Private Function EncryptIt(ByVal password as string, ByVal strEncryption_Type as EncType)
' Your encryption code here
Return encryptedPassword
End Function
 
Private Enum EncType
   MD5,
   SHA1,
   SHA256
End Enum
  


-------------
http://baumannphoto.com" rel="nofollow - Blog | http://mpgtracker.com" rel="nofollow - MPG Tracker


Posted By: Misty
Date Posted: 11 May 2005 at 1:18am
Originally posted by Mart Mart wrote:

Well do you have a function called encrypt it? And if so have you imported the namespace it is in? I.e. if its in the namespace MyEncryption.CryptoStuff you need to put a

<%@ Import NameSpace="MyEncryption.CryptoStuff" %>

or

Imports MyEncryption.CryptoStuff

or

using MyEncryption.CryptoStuff;

where applicable
 
This didn't work. I got an error message when I used the name space above. I realized that I had forgotten to add a function. I added a function. It works fine now.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net