Results 1 to 6 of 6
  1. #1
    lumiere is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2019
    Posts
    6

    Code to Encrypt password not working

    Hi,



    I am making a database for recording the transactions of a small shop.
    As it would be used by different people, I decided to introduce a login form where different users have to enter their respective passwords for logging in.
    After entering password, I thought it was better to encrypt the password.

    I downloaded an encryption algorithm for vba from internet. The function takes in a string (password to be encrypted), a secret key and an Optional Boolean variable.
    The algorithm seems to work if the Boolean is set to false but gives error on compiling if set to true.

    I have attached a copy of a database with just the function of entering a password and its subsequent encryption.
    I would be greatly thankful if someone has a look in it and help me to sort out the error.

    The encryption algorithm was downloaded and imported as a seperate class. After downloading, I tried to run it but it was giving an error, so I added 'PtrSafe' in the Private Declaration line of the code.
    The optional boolean variable I talked about seems to convert the encoded string to Unicode.
    The error that occurs is the 'Compile Error : Type Mismatch' and VarPtr is highlightd. My machine is a 64-bit. I tried to look online for the solution and saw that Long should be replaced with LongPtr.
    I tried that but that lead to a new 'Type mismatch' error, at some other part of the code.

    I am not experienced in cryptography. Can someone please help me.
    Attached Files Attached Files

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,421
    are you running 64 bit access? the bitness of the machine is irrelevant.

    The implication of setting the boolean to true is that you are running 32bit access.

    To check, go to File>Help - you should see the access bit size off to the right

  3. #3
    lumiere is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2019
    Posts
    6
    Thanks for the reply.

    I am running 64 bit access.

    So, if I run the code on 32-bit access, there would be no errors?

  4. #4
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    I did a quick test earlier. There were still issues using 32-bit Access though in that bitness it does compile.
    You do need to add the line Option Explicit to the form module and fix the compilation errors
    For example, are you aware the CopyMemory API is listed twice in the class module?

    Anyway, I found it almost unusable taking anything well over a minute to return an encrypted password and crashing repeatedly.

    If you are interested I have an example database using 128-bit RC4 encryption for passwords
    http://www.mendipdatasystems.co.uk/p...gin/4594469149
    Last edited by isladogs; 08-06-2021 at 09:17 AM.
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  5. #5
    lumiere is offline Novice
    Windows 7 64bit Access 2016
    Join Date
    Dec 2019
    Posts
    6
    Quote Originally Posted by isladogs View Post
    I did a quick test earlier. There were still issues using 32-bit Access though in that bitness it does compile.
    You do need to add the line Option Explicit to the form module and fix the compilation errors
    For example, are you aware the CopyMemory API is listed twice in the class module?

    Anyway, I found it almost unusable taking anything well over a minute to return an encrypted password and crashing repeatedly.

    If you are interested I have an example database using 128-bit RC4 encryption for passwords
    http://www.mendipdatasystems.co.uk/p...gin/4594469149
    Thanks for your input and sorry for such delay in response from my end.

    I copied the class code from a website. And I noticed CopyMemory was listed twice.
    I tried the above code on a number of systems and some of them have quite slow responses, some of them ranging in order of minutes. So I guess the code is unusable for practical purposes. I have looked at RC4 encryption module and it is quite intriguing.
    I wanted to ask, is it open source and can be used by anyone?

    However I want to mention that I succeeded in converting my original code to be usable for 64-bit
    systems. I had to change some 'long' to 'longptr' in CopyMemory statement and some others to
    'longlong'.
    I will share the class if anyone's intrested.
    Thanks.

  6. #6
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,975
    RC4 encryption is freely available and is open source. Its also very fast, reliable and works in both 32/64-bit!

    For info, you should never need to use LongLong when converting API code
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

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

Similar Threads

  1. Password protect/encrypt a field in an Access form
    By ndesforges in forum Programming
    Replies: 12
    Last Post: 10-22-2019, 04:26 PM
  2. Replies: 2
    Last Post: 01-15-2014, 07:57 PM
  3. Password validation not working
    By nika.duncan in forum Access
    Replies: 4
    Last Post: 11-22-2013, 11:01 AM
  4. Change Password field in Table not working
    By bongazi in forum Programming
    Replies: 4
    Last Post: 05-18-2011, 04:33 PM
  5. Login/Password Code not working
    By eww in forum Programming
    Replies: 3
    Last Post: 09-21-2010, 10:49 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