Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Using cipher to encrypt
Message
De
11/11/2004 15:41:13
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 8
OS:
Windows 2000 SP4
Network:
Windows 2000 Server
Database:
Visual FoxPro
Divers
Thread ID:
00960312
Message ID:
00960623
Vues:
9
>But when I log in with my password it gives me password invalid. Here is my code for the onclick event for logging in:
>
>
>LOCATE FOR UPPER(login.userid) = UPPER(ALLTRIM(THISFORM.UserName.DisplayValue))
>
>IF .NOT. ENCRYPT(thisform.Password.Value, "aqwsrweq") == Login.password
>		WAIT WINDOW "The user name or password is incorrect. Please try again." TIMEOUT 1.5
>		THISFORM.Password.Value = ""
>		THISFORM.Password.SetFocus	
>	ELSE
>		thisform.release
>ENDIF
>
>
>Similarly, here is my code for the onclick event when creating a user:
>
>
>INSERT INTO 'login' ( userid, password) ;
>VALUES  (thisform.username.value, thisform.password.value)
>
>REPLACE password WITH ENCRYPT(thisform.password.Value, "aqwsrweq")
>		
>thisform.username.value=""
>thisform.password.Value=""
>


As Borislav said, make sure lengths of comparison are igual. Either PADx() or as he also suggested use ALLTRIM() in both sides of the equation.

Note: In your example I see you read the entered value directly from the screen (ThisForm.Password.Value). That opens a security hole as you seemingly don't validate what they are allowed to enter before using it (opening yourself to SQL injection and other malicious types of code). It is best to save it to a variable or property then validate it to be within accepted parameters (min and max sizes, accepted characters only, password complexity requirements, etc.) before actually using it for the query.

HTH


Alex Feldstein, MCP, Microsoft MVP
VFP Tips: English - Spanish
Website - Blog - Photo Gallery


"Once again, we come to the Holiday Season, a deeply religious time that each of us observes, in his own way, by going to the mall of his choice." -- Dave Barry
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform