Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2016
    Posts
    3

    A simple login forum that sadly I seem to have failed at

    Hi guys,




    so I followed this video tutorial on how to make a log in form

    https://www.youtube.com/watch?v=356ylQn6kkA , and I added a few extra things using the code shown.

    If rs!pinA <> Encrypt(Me.Text5, "") Then
    Me.Label12.Visible = True
    Me.Text5.SetFocus
    Exit Sub
    End If
    Me.Label12.Visible = False

    please note that the Encrypt is not initially in the form but is added later. Anyway this is for a personal dB project to store my account info in, with more login info required than a simple MS Word encrypted doc, partly for security reasons and partly because I need something to do. So when the "SUBMIT" button is activated it runs through this code and basicly it looks for the first username in the table, then checks to make sure the password and both pins (intended to be 4 didget number pins) entered in the form match the record in the table that match the username found. now before I added the encrypt in the whole thing worked perfectly, and if anything was wrong then it would show a red error message saying "incorrect pin or what ever the error type was."

    But for shits and giggles I wanted to try my hand at hashing passwords so I watched this tutorial by the same person. And followed it step by step, changed the values in the table as if they had been hashed so that when I tried running the code it would work. unfortunately when I clicked submit I got this error with the first encrypt highlighted.

    I have been unable to work out what I am getting wrong was hoping someone more familiar with this could see my mistake and point it out, thanks.


    Sam



    This is the only other code in here, it as I understand it is the algorithm for this encrypt method. (although I could be wrong)

    Code:
    Option Compare Database
    Option Explicit
    
    Global g_Enabled As Boolean
    Public Const Salt As Long = 69125478
    
    
    Public Function Encrypt(strIn As String) As String
        Dim strChr As String
        Dim i As Integer
        
        For i = 1 To Len(strIn)
            strChr = strChr & CStr(Asc(Mid(strIn, i, 1)) Xor Salt)
        Next i
        Encrypt = strChr
    End Function
    Last edited by June7; 01-14-2016 at 10:53 AM. Reason: add CODE tags

  2. #2
    Join Date
    Jan 2016
    Posts
    3

    simple login form issue with hasshing passwords (newbe)

    Hi guys I am making a dB for a local pc to store account info in, my usernames passwords pins etc, at the moment I use an encrypted word document but its not a very good way of storing this info, I was board so thought why not make a dB and see how much I remember from high school computing.

    I followed this tutorial https://www.youtube.com/watch?v=356y...uJpHrcFj0vYZjW - how to make one
    and could get it working, please note I have added two extra fields in the forum that also have to match with two feilds in the table so to log in you would need username pin A, pin B and the password. I did this just by using the same code as the password part, only I changed the buzz words, so that it checked each field correctly.


    anyway I wanted to have an encrypted version partly so if the user table was ever open no one could see my passwords but also for something to do, so I watched this one https://www.youtube.com/watch?v=x4FA...uJpHrcFj0vYZjW - hashing passwords. However i get this error when I run the function https://gyazo.com/f3dc4b4e268761468819245f2c2d0af6 with the first encrypt highlighted.
    I can't seem to work out what I have done wrong was hopping someone might be able to tell me, here is my code:

    Global module code:
    Code:
    Option Compare Database
    Option Explicit
    
    
    Global g_Enabled As Boolean
    Public Const Salt As Long = 69125478
    
    
    Public Function Encrypt(strIn As String) As String
        Dim strChr As String
        Dim i As Integer
        
        For i = 1 To Len(strIn)
            strChr = strChr & CStr(Asc(Mid(strIn, i, 1)) Xor Salt)
        Next i
        Encrypt = strChr
    End Function
    
    
    run code:
    Option Compare Database
    Option Explicit
    
    
    Private Sub Command19_Click()
       Dim rs As Recordset
       Dim db As Database
       
       Set db = CurrentDb
       Set rs = db.OpenRecordset("accessaccountinfo", dbOpenSnapshot, dbReadOnly)
       
       
       
       rs.FindFirst "uname='" & Me.Text0 & "'"
       
       If rs.NoMatch = True Then
         Me.Label11.Visible = True
         Me.Text0.SetFocus
         Exit Sub
        End If
         Me.Label11.Visible = False
       
       If rs!pinA <> Encrypt(Me.Text5, "") Then
        Me.Label12.Visible = True
        Me.Text5.SetFocus
        Exit Sub
       End If
       Me.Label12.Visible = False
       
       If rs!pinB <> Encrypt(Me.Text7, "") Then
        Me.Label12.Visible = True
        Me.Text5.SetFocus
        Exit Sub
       End If
       Me.Label12.Visible = False
       
       If rs!Password <> Encrypt(Me.Text9, "") Then
        Me.Label12.Visible = True
        Me.Text5.SetFocus
        Exit Sub
       End If
       Me.Label12.Visible = False
       
       If rs!status <> "active" Then
       Me.Label22.Visible = True
       Exit Sub
       End If
       
       DoCmd.OpenForm "renameme"
         
           
    End Sub
    Sorry I know that the field and text names are not helpful but I didn't have a reason to make them be as this is just for personal use.


    tia

    sam
    Last edited by June7; 01-14-2016 at 10:52 AM. Reason: add CODE tags

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    The Encrypt() function has 1 argument, you are passing 2 parameters - the second is empty string (""). Try concatenating:

    If rs!pinA <> Encrypt(Me.Text5 & "") Then


    NOTE: I edited your posts to put the longer code between CODE tags so indentation is retained and easier to read.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    Join Date
    Jan 2016
    Posts
    3
    Thanks for your help!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 04-17-2015, 10:59 AM
  2. Need a simple LOGIN mechanism
    By djcmalvern in forum Programming
    Replies: 1
    Last Post: 03-29-2013, 01:32 PM
  3. Replies: 1
    Last Post: 02-17-2013, 06:54 AM
  4. Converting dBase forum to Access forum
    By amerifax in forum Forms
    Replies: 5
    Last Post: 07-03-2012, 01:12 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums