Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Where to store passphrace
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows XP
Database:
MySQL
Divers
Thread ID:
01335597
Message ID:
01335766
Vues:
13
Christof & Carlos,

For passwords that makes sense, I think I have to change that. I need to look for a C# dll though, because I need to access the password also from another NET application.

But what about passwords that need to be sent decrypted, like a password for the database backend?

>Hi Christian,
>
>never store passwords, only hashes. Generating a hash in VFP is relatively easy:
>
>*========================================================================================
>* Returns the hash value of a string.
>*========================================================================================
>LParameter tcString
>
>	#include wincrypt.h
>
>	Local loCrypt, lcHash
>
>	* Special version of _CryptAPI that doesn't hide all methodss
>	loCrypt = NewObject("_CryptApi","_CryptX.vcx")
>	
>	Local lnHashHandle, lnRet, lnLength, lcHash
>	lnHashHandle = 0
>	lcHash = NULL
>	loCrypt.CryptCreateHash( loCrypt.hProviderHandle, dnCALG_SHA, 0, 0, @lnHashHandle )
>	
>	If loCrypt.nlastapierror = 0
>		loCrypt.CryptHashData( m.lnHashHandle, m.tcString, Len(m.tcString), 0 )
>		If loCrypt.nlastapierror = 0
>			Declare Long CryptGetHashParam in Win32API ;
>  			Long hHash, ;
>  			Long dwParam, ;
>  			Long @pbData, ;
>  			Long @pdwDataLen, ;
> 				Long dwFlags
> 			lnLength = 0
>			lnRet = CryptGetHashParam(m.lnHashHandle, dnHP_HASHSIZE, @lnLength, 4, 0)
>			If m.lnRet # 0
>				Declare Long CryptGetHashParam in Win32API ;
>	  			Long hHash, ;
>	  			Long dwParam, ;
>	  			String @pbData, ;
>	  			Long @pdwDataLen, ;
>	 				Long dwFlags
>	 			lcHash = replicate( Chr(0), m.lnLength )
>	 			lnRet = CryptGetHashParam(m.lnHashHandle, dnHP_HASHVAL, @lcHash, m.lnLength, 0)
>	 			If m.lnRet == 0
>	 				lcHash = NULL
>	 			EndIf
>			EndIf
>		EndIf
>		loCrypt.CryptDestroyHash( m.lnHashHandle )
>	EndIf
>
>
>Return m.lcHash
>
>This code assumes that you have a modified version of the _CryptApi.vcx library which has all hidden members set to public. On Vista you can avoid the VCX altogether. Let me know if you also need a Vista-only code sample.
Christian Isberner
Software Consultant
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform