Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to store encrypted data
Message
De
09/05/2006 20:36:19
James Blackburn
Qualty Design Systems, Inc.
Kuna, Idaho, États-Unis
 
 
À
09/05/2006 18:07:35
Gary Foster
Pointsource Consulting LLC
Chanhassen, Minnesota, États-Unis
Information générale
Forum:
Visual FoxPro
Catégorie:
Client/serveur
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Database:
MS SQL Server
Divers
Thread ID:
01120561
Message ID:
01120579
Vues:
19
Gary,

Here is what I did.
DEFINE CLASS cpassword AS tools OF tools.vcx 
	crawpassword = ""
	cencpassword = ""
  cEncKey = ""
  nEncType = 2
  nEncMode = 0
  
  FUNCTION init()
	  IF NOT "vfpencryption.fll" $ LOWER(SET("Classlib"))
	  	SET LIBRARY TO vfpencryption.fll
	  ENDIF 
  ENDFUNC
  
	FUNCTION newpassword()
	  LOCAL LCRET 
	  this.crawpassword = "PWD"+SYS(3)+SYS(2015)
		this.cencpassword = this.encrypt(this.crawpassword)
		RETURN this.crawpassword 
	ENDFUNC
	
	FUNCTION isEncryptEd(tcPassword)
		LOCAL llRet 
		llRet = LEN(CHRTRAN(UPPER(tcPassword)," 1234567890ABCDEFGHIJKLMNOPQRSTUVWZYX_","")) > 0

		return llRet 
	ENDFUNC
	
	FUNCTION Conv_encrypt(tcPassword)
		LOCAL lcRet 
		lcRet = ""
		IF NOT EMPTY(tcPassword) AND VARTYPE(tcPassword) = "C"
			lcRet = this.encrypt(tcPassword)
			lcRet = STRCONV(lcRet,15)
		ENDIF 
		return lcRet 
		
	ENDFUNC
	
	FUNCTION encrypt(tcPassword)
		LOCAL lcRet 
		lcRet = encrypt(tcPassword,this.cEncKey,this.nEncType,this.nEncMode)
		return lcRet 
	ENDFUNC
	
	FUNCTION Conv_decrypt(tcPassword)
		LOCAL lcRet 
		lcRet = ""
		IF NOT EMPTY(tcPassword) AND VARTYPE(tcPassword) = "C"
			lcRet = STRCONV(tcPassword,16)
			lcRet = this.Decrypt(lcRet)
		ENDIF 
		return lcRet 
	ENDFUNC
	
	FUNCTION Decrypt(tcPassword)
		LOCAL lcRet 
		lcRet = decrypt(tcPassword,this.cEncKey,this.nEncType,this.nEncMode)
		lcRet = CHRTRAN(lcRet,CHR(0),"")
		return lcRet 
	ENDFUNC
	
ENDDEFINE
>Hi all,
>I'm experimenting with encryption using the VFPEncryption71.fll. It seems to work well, but I don't know how to pass the encrypted string to SQL Server. I created a VARBINARY field for this but don't know the syntax for the UPDATE or INSERT.
>
>
>UPDATE SomeTable SET EncField = BinaryGobbledygook WHERE PK = 123
>
>
>Fails with error "Incorrect syntax near..."
>
>
>UPDATE SomeTable SET EncField = 'BinaryGobbledygook' WHERE PK = 123
>
>
>Fails with error "Disallowed implicit conversion..." because of embedded quotes.
>
>Anyone succeed with this or perhaps I need a different way to store encrypted data.
>
>Thanks.
>
>Gary
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform