Several implementation methods for software login
Now many software have a login confirmation window to determine the user's use permission. These login windows can determine the function module provided by the user or directly to the user name and password, you have no right to use this software! " So, how is these login functions? Based on my own practical use of this functionality into the following implementation methods, I specifically: 1. When writing code, it is the easiest to add the password in the program. By comparing the user's input and the original setting of the original settings, if the same is legal user, otherwise, you will see if you are willing to make this brother. The specific implementation code is as follows: Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT); begin if edit1.text = 'password' Then Begin ShowMessage ('Hello!');... Else Begin ShowMessage ('You Cannot Enter!) , Close; End; End; As you know, simple things tend to have a lot of shortcomings. Although this method is simple, there are many shortcomings, and its cryptographic validation is given when programming, and it is impossible to change, so that the flexibility of the password is very poor! 2. By reading a password file, this method is to store the authenticity identifier in a directory of the hard disk in a directory, which is generally hidden and is not easy to discover. The specific implementation code is as follows (assuming that the authentication file already exists): var passwordfile: textfile; s: string; begin assignfile (passwordfile, 'passwordfile.txt'); reset (passwordfile); readln (PasswordFile, s); if Edit1. Text = s dam closefile (passwordfile); showMessage ('Hello!');... Else Begin Closefile (PasswordFile); ShowMessage ('You Cannot Enter!'); Close; End; End; This method can be After the program is compiled, it can still change the authentication ID, but because the identity is existing in the form of a file, it is easy to discover or unintentionally deleted by others, so that it does not implement the predetermined function.
In order to make the identity files not destroyed, it can store it under the system folder and set it to hide it. More enabling to make the simple text file operation to the operation of the dynamic connection library file, which makes it improving. 3. Thoughts of the method of authentication by registry operations are to add items to the registry and pay the value, and compare the values of the specific item in the registry when running the program each time the program is run. function Wsz_CheckUser (MyUser: string; MyPass: string): Boolean; var sUser: string; sPass: string; begin result: = false; RegF: = TRegistry.Create; RegF.RootKey: = HKEY_LOCAL_MACHINE; RegF.OpenKey ( "SOFTWARE / Microsoft / WHH726 ", TRUE); SUSER: = Regf.readstring (" user "); spass: = regf.readstring (" pass "); if (SUSER = myuser) THEN Result: = true; Regf.free; end; this method is better, and it is relatively simple. In order to improve its security, it is also possible to operate in several different items. When the performance is added, the comparison of each item can make the identity test more secure. This article focuses on the implementation of several software logins, and the examples are relatively simple. If you are interested, you can expand your changes to your needs. The example in the article is debugged in Delphi 6 Win2000.