Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Encrypting
Message
De
28/08/2002 07:32:21
 
 
À
28/08/2002 07:09:03
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Titre:
Divers
Thread ID:
00694362
Message ID:
00694365
Vues:
8
You can use the Windows Crypto API in your program, take a time to read the VFP7 help, it talks about it. Also, you can specify some sort of "code" to your table to encrypt it.
An example:
******
* This Routine returns a 2-char string from a Logic Value to be processed by * LogicDecrypt
***

Procedure LogicEncrypt
	Lparameters lVal
	Local cChar1,cChar2,nValTrue,nValFalse
	nValTrue =10
	nValFalse=13


	cChar1=rand()*255

	If lVal
		cChar2=bitxor(cChar1,nValTrue)
	Else
		cChar2=bitxor(cChar1,nValFalse)
	Endif

	Return chr(cChar1)+chr(cChar2)

Endproc

******
* This Routine returns a logic value from a 2-char string generated by 
* LogicEncrypt
***

Procedure LogicDecrypt
	Lparameters cLogico
	Local cChar1,cChar2,lVal,nValTrue,nValFalse
	nValTrue =10
	nValFalse=13

	cChar1=asc(substr(cLogico,1,1))
	cChar2=asc(substr(cLogico,2,1))
	lVal  =.F.

	If cChar2=bitxor(cChar1,nValTrue)
		lVal=.T.
	Endif

	Return lVal
Endproc


******
* This Routine encrypts/decrypts a string. no additional parameters are 
* necessary
***
Procedure CRYPT
	Lparameters cString
	Local cSenha,i,j,k,nCharString,nCharSenha,nChar,cNovaString

	cSenha=chr(9)+chr(27)+chr(13)+chr(10)+chr(27)+chr(9)+chr(9)+chr(10)+chr(13)

	cNovaString=""
	i=1
	j=1
	k=1
	nCharString=0
	nCharSenha =0
	nChar=0

	For i = 1 to len(cString)
		If j > len(cSenha)
			j=1
		Endif
		nCharString=asc(substr(cString,i,1))
		nCharSenha=asc(substr(cSenha,j,1))


		nChar =	BITXOR(nCharString,nCharSenha)

		cNovaString=cNovaString+chr(nChar)
		j=j+1
	Endfor
	Return cNovaString
Endproc
Tell me if it works
Pablo Márcio de Oliveira

Inside the scream is silent, inside it must remain
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform