473,387 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I use Encryption with my Password Control

Hello.

How would I apply SHA2 Cryptographic Hash Algorithm for VBA and VBScript to a password control on a form?

Thanks
Mar 11 '12 #1
19 1986
Rabbit
12,516 Expert Mod 8TB
You run the input through the function before storing it in the table.
Mar 12 '12 #2
NeoPa
32,556 Expert Mod 16PB
And when a password is entered on your form as credentials, you run it through the encryption algorithm and compare the result with what was stored.
Mar 12 '12 #3
Could this be in the AfterUpdate method??
Mar 12 '12 #4
NeoPa
32,556 Expert Mod 16PB
It could be, but for something like this you typically want to allow the operator to make changes before confirming the credentials to use, so you put the code behind a Command Button.
Mar 12 '12 #5
Ok so if I create a new operator, I should have the password field. Enter the desired password and on the click of the command button to create the operator I should enter the code!

The code: can it be saved as a module and then be called back on the click of the button?
How do I call it then?
Hope my question is clear?
Mar 12 '12 #6
NeoPa
32,556 Expert Mod 16PB
Ryno Bower:
Ok so if I create a new operator, I should have the password field. Enter the desired password and on the click of the command button to create the operator I should enter the code!
You call the code passing your actual password, then save the returned value in your table.

Ryno Bower:
The code: can it be saved as a module and then be called back on the click of the button?
Yes. It's saved in a module. There's no other way I know of using it.

Ryno Bower:
How do I call it then?
You say something like :
Expand|Select|Wrap|Line Numbers
  1. SavedPassword = SHA(Me.txtPassword)
Mar 12 '12 #7
Rabbit
12,516 Expert Mod 8TB
A quick note about the return value of the function, it returns a 32 byte array. You will have to convert that to a string before storing it in a field. You can either store the hash as its byte for byte string equivalent (nonprintable characters and all) or you can store it as a more human friendly hexadecimal string. The former uses less space but can't be read by a human and the latter is the opposite.
Mar 12 '12 #8
I need help!
I have created the code (module) and called it PasswordCode.

I have a form and on the form is fields UserName linked to the underlying table.
Also I have an unbound text field called txtPassword with the password input mask.
Also I have the password field linked to the underlying table callled SavedPassword.

Also I have a button. I have the code as you suggested when I click the button.
SavedPassword = SHA(meMtxtPassword)

When I click the button it should insert the encrypted password into the SavedPassword field right?

I get an error message that the value you entered isn't valid for this field.

Is my code right?
Mar 12 '12 #9
Rabbit
12,516 Expert Mod 8TB
Refer to my previous post.
Mar 12 '12 #10
Would it look something like this?
Expand|Select|Wrap|Line Numbers
  1. Dim spw As String
  2. spw = me.SavedPassword
  3.  
  4. Spw = SHA(me.txtPassword)
I still get error 94: invalid use of null

Please help
Mar 12 '12 #11
Rabbit
12,516 Expert Mod 8TB
You didn't pick one of the two options I laid out in post #8. But whichever option you decide to choose, that's not what it would look like. At a minimum, you would need a loop to iterate through the array that's returned.
Mar 12 '12 #12
Could you give me a sample code?
This is confusing to me.
I thought that I made the field a string as you said earlier!

Thanks
Mar 12 '12 #13
Rabbit
12,516 Expert Mod 8TB
I don't see anything in your code that changes the 32 byte integer array into a string.

Here's an example of a loop.
Expand|Select|Wrap|Line Numbers
  1. Dim i, j
  2. j = 0
  3. For i = 0 To 31
  4.    j = j + 1
  5. Next
It adds 1 to j 32 times.
Mar 12 '12 #14
Ok thanks.

But I don't think ill know to interpret that into changing the field toa string!
I guess I am just to dumb to understand it!
Mar 12 '12 #15
Rabbit
12,516 Expert Mod 8TB
What you should do is find a good VBA tutorial and have a go at that before returning to this.
Mar 12 '12 #16
NeoPa
32,556 Expert Mod 16PB
Ryno Bower:
I guess I am just to dumb to understand it!
We all start somewhere Ryno.

What is certainly less than clever is to ask for help with the very basics of code without first putting some effort into getting to speed up to at least that level. You wouldn't ask a heart surgeon to put a plaster on for you. You would be expected to manage that all by yourself. It's basic, and easily achievable, with a minimum of effort and without the need to ask for assistance.
Mar 12 '12 #17
Any suggestions where I could find tutorials on VBA?
Mar 13 '12 #18
By the way! If I get this right, will the password show as ******?
Mar 13 '12 #19
NeoPa
32,556 Expert Mod 16PB
Ryno Bower:
Any suggestions where I could find tutorials on VBA?
Try theses :
  1. Microsoft Access Tutorials (Strive4Peace).
  2. Microsoft Access Tutorials
  3. Microsoft Office Tutorials.
  4. VBA Tutorial (Excel).

They may not all suit you but I expect you'll find some of them very helpful.

Remember though, you may need a better understanding of the fundamentals of coding too. These can help with that to a limited extent, and they're what I have as I work in this area. Try some of them and see if this thread makes more sense to you. If not, look out for something that deals with the fundamentals of programming, rather than these which are are MS Office-specific.

Ryno Bower:
By the way! If I get this right, will the password show as ******?
On your form it will show that way as it is only ever shown when the operator types it in. You should never display a saved password, even though it's in an encrypted form.
Mar 13 '12 #20

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Klaus Kragelund | last post by:
Hi I'm using DreamWeaver 2004 on a Win2k machine to create my homepage. After spending several hours of mingling with ASP I discover that my ISP doesn't support Access databases. So I turned to...
2
by: Jerry | last post by:
Is there a webforms equivalent to the HTML password box control? I don't see one in the toolbox. Regards
0
by: Pavan | last post by:
Hi All, I am using Password Recovery control in order to reset my hashed passwords in ASP .Net 2.0 Beta 2. The system generated password is too difficult to remember, so i am giving Change...
1
by: John | last post by:
Hi I am using the Change Password control which works fine and changes the password. I have two problems; 1. After password has been changed, pressing continue goes no where. How can I tell...
1
by: xpcer | last post by:
Hai everybody i have an question, if we use mysql, we can encrypt our password using md5() function, other wise, i want to encrypt my password in sql server 2000, can anyone tell me, what...
2
by: =?Utf-8?B?V2FubmFiZQ==?= | last post by:
I added a change password control to my application and when I run the page that has it, I get an error: Generating user instances in SQL Server is disabled. Use sp_configure 'user instances...
7
parshupooja
by: parshupooja | last post by:
Hi I have created a login page which has user name n password. After entering values it authenticate from SQL Server and if it is correct, it forwards to designated page otherwise shows invalid...
2
by: olafinsbraaten | last post by:
I am using column-level encryption (ENCRYPT_CHAR, DECRYPT_CHAR) to protect selected columns in DB2 LUW v.9.1 and v.9.5 on Linux. The ultimate goal is to support the requirements put forward in...
4
by: zacks | last post by:
I'm not sure when it came into being, since this it the first time I have worked very much with a password control in .NET, but if a textbox that has a non-empty value for PasswordChar or the...
0
by: Jon.Hakkinen | last post by:
Hi all, I'm on DB2 9.5 fp 0 on Windows. I have a simple SQL stored procedure which uses the Encrypt() function to insert data in a table. I do not set the encryption password inside the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.