Answered by:
'Not declared' error in Hash code

Question
-
User-1793215261 posted
Hello
Following this tutorial http://www.visual-basic-tutorials.com/hasing-password-with-salt-in-visual-basic.htm and, in particular, this Private sub,
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click hashedPasswordText.Text = (Hash512(plainPasswordTxt.Text, CreateRandomSalt)) End Sub
I am getting a blue underline error (VS 2017) with this line in my own code:
Private Sub btnReg_Click(sender As System.Object, e As System.EventArgs) Handles btnReg.Click hashedPasswordText.Text = (Hash512(plainPasswordTxt.Text, CreateRandomSalt))
as 'hashedPasswordText' and 'plainPasswordTxt' is not declared. What is it expecting, please (the ID of the password field in my own form is 'password' as is the name of the password column in my Access database - obviously, there is no hashedPasswordText field in my form, but there is a text column in my database called Hash. A yellow light bulb appears alongside this line of code with the following suggestions:
Generate method 'register.Hash512' Generate property 'register.Hash512', Generate variable 'plainPasswordtxt', Generate variable 'hashedPasswordText'
Thank you.
Saturday, August 18, 2018 9:40 PM
Answers
-
User409696431 posted
The error is clear: you haven't got any TextBox or other control with a Text property defined as hashedPasswordText or plainPasswordTxt.
The page you link to shows an image of a form. I assume that form is supposed to have "plainPasswordTxt" as the id of the first field that takes the input, and "hashedPasswordText" as the id of the second field, that shows you the result.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, August 19, 2018 12:58 AM
All replies
-
User409696431 posted
The error is clear: you haven't got any TextBox or other control with a Text property defined as hashedPasswordText or plainPasswordTxt.
The page you link to shows an image of a form. I assume that form is supposed to have "plainPasswordTxt" as the id of the first field that takes the input, and "hashedPasswordText" as the id of the second field, that shows you the result.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Sunday, August 19, 2018 12:58 AM -
User-1793215261 posted
Thanks, Kathy.
I thought as much and have now replaced 'plainPasswordTxt.Text' with the ID of my own password text field, so now I have:
hashedPasswordText.Text = (Hash512(password.Text, CreateRandomSalt))
That has removed the error concerning 'plainPasswordTxt', but what to do with the error relating to 'hashedPasswordText.Text' because there is no text field in my form to show what the hashed password looks like. That hashed password is only stored in my online MS Access database - that is the whole point of it.
Thanks again.
Sunday, August 19, 2018 5:01 AM -
User409696431 posted
Rather obviously, remove the code that puts the hashed password on the page on a button click. You were following an example that showed you the hashed password on the page when that button was clicked. For real life, you wouldn't do that.
Please mark the answers that solved your problem.
Sunday, August 19, 2018 5:01 PM