Encryption decryption vb 6.0


















The problem lies in the codng. How shall I get it done? Hi, Thank you for your time. I studied only for a brief term in VB 3 years ago and my skill is not good enough to understand the coding. What I actually want is just to write a simple code - e. When I next login into the database with the input "abcd" it will then convert this string back to "defg", checked it against the database. If it is correct, then it will allowed me to login.

This will work for all text input as long as you don't use the last three characters of the standard ASCII character set, which I sincerely doubt will be used since they are special characters. Thank you for your codes. I managed to work out a solution. It seems to work all right. But each time I tried to encrypt, the encrypted password is appended to the first encrypted password.

However the second time I encrypt with mno, the encrypt password become defpqr instead of just pqr. What is wrong with my coding? Please see the attached zip. Would appreciate if you could tell me why this happen.

A few pointers and critique here if you are one of those people who can't stand criticism, stop reading, your answer is above. Point 1 Indent Your Code I know that on small projects, it's no big deal Indenting is a necessary part of programming and debugging, and regardless of project size, should still be adhered to. Ideally, The code should be:. Point 2 Code Placement You test if the textbox is empty, After you perform the operation on the textbox You should test it first, because even though the for loop doesn't care if the textbox is empty, if it was different scenario, where it wrote it to a database or used it in some other means, you could encounter some problems.

It operates the same for the most part, with the exception that it's a lot faster. I don't always do it, but it's something that's really good to know and a practice that's really good to be in. This means that they will retain their value for the whole run of the program, therefore, when you encrypt a new password the variable Result already contain the current encrypted password and hence the new password is appended.

You should take the habit of having as few public variables as possible in your programs, using parameters to pass values to functions and subs or letting each sub in a form read the values from the controls instead. This makes for better code, easier debugging since you don't have to worry about what has been done to the vaiable somewhere else and more variables available since you can use the same names is different subs. So your solutions are the following: 1 Move the variable declarations inside the Click event handler, i.

I strongly suggest the first for the reasons stated above but the second option will work as well. In truth I agree with Yomet on this I didn't want to delve into variable scope, because some people have a real hard time understanding scope Thanks for the pointer about vbNullString, I had no idea that it would speed the application and will start using it immediately.

Hi Comatosa and Yomet, Thank you for your feedback and help. One last question. I have tried the codes and link it to my Access database and it works. Let say I add a command button called Login on the same form, when I click on it, it will verify the encrypted password that it saves earlier and match it to the database.

It will then let me login if the password is the same and reject me if it is not. Would appreciate if you could guide me to write the coding. Please see attached zip. Hi Comatose and Yomet, First my apology to Comatose for spelling your name incorrectly. I have just found out that when I key in any password with the letter "y", e. It gives" Error inserting, syntax error in string n query exp dfkw". What does that mean? Thank you. Hi, Can someone please tell me why I get the error msg "Run-time error '91' object variable or with block not set" when I tried to save my encrypted password.

I have used the same coding from the main form OrderDetails and it works fine but not for this saving of password.

Please take a look at the zip files. I appreciate your comment and help. I want to help you but I cannot continue without the updated project. A little hint, move your "Save. Hi Yomet, Thank you very much for your reply. While waiting for solution to my problem with the coding, I have through tried and error for the past few days and finally get to finish my project.

TechnologyAdvice does not include all companies or all types of products available in the marketplace. Remember Me? Advertiser Disclosure. Advanced Search. Results 1 to 34 of Thread Tools Show Printable Version. May 2nd, , AM 1. Source code Code:. Last edited by wqweto; Dec 9th, at PM. Reason: openssl compatibility.

May 2nd, , AM 2. QQ: Aug 26th, , PM 3. Aug 27th, , AM 4. Sep 15th, , AM 5. Attached Files AESecb. Sep 15th, , AM 6. Sep 15th, , PM 7. Sep 17th, , AM 8. Last edited by wqweto; Jul 21st, at AM. Sep 17th, , AM 9. Originally Posted by wqweto. Mar 16th, , AM May 15th, , PM Can't English. May 16th, , AM May 16th, , PM Jul 28th, , PM Thanks Rob. Jul 29th, , AM Hi, This is brilliant with so little code. Jul 8th, , AM Many thanks,. What i am to do is: 1 Allow the user to specify some text and a password 2 Encrypt and write that encrypted text into a text file 3 Later the user should be able to Specify the password and retrieve that text from the file decrypted I can write the encrypted test to a file, but when i try to retrieve it, it fails Write value to file Code:.

Jul 8th, , PM Jul 9th, , AM Re: [VB6] Simple AES bit password protected encryption Thank you Arnoutdv and everyone, I have it working now, i was going crazy trying to figure out why i kept on getting a type mismatch error, then it occured to me, when i defined my variable, i did not define it as an array ie i had dim LineText as byte instead on Dim LineText as byte its now working.

Dec 8th, , AM Source code thinBasic Code:. Option Explicit. DefObj A-Z. End If. HmacHashLen As Long. Nonce 0 To 1 As Long. EncrData As Byte. EncrPos As Long. LastError As String. End Type. Dim baData As Byte. Dim sError As String. Raise vbObjectError, , sError. End Function. Dim vErr As Variant. Dim bHashBefore As Boolean. Dim bHashAfter As Boolean. Dim baTemp As Byte. Dim lPtr As Long. Reply to this Topic. This topic is old! No one has contributed to this discussion in over 12 years.

Are you sure you have something valuable to add to revive the existing conversation? Consider starting a new topic instead. Otherwise, please be thoughtful, detailed and courteous, and adhere to our posting rules. Edit Preview. H1 H2. Post Reply. Broken Link. Go Back to the Post Continue Anyways.

Share Post. Permanent Link.



0コメント

  • 1000 / 1000