Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Registration KEY
Message
De
14/03/2003 16:48:24
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00766017
Message ID:
00766038
Vues:
33
Hi Hector,
I just tried your code. If you run the code below, can you tell me why when the 2nd time through runs (encrypting and unencrypting the name) it displays strange characters using ? "Encrypted Name:"
* description: Encrypts cString with value passed in cMask
* using Bit XOR operation.
*
* Bit XOR operation works like this:
* XorIt( A, B ) -> C
* XorIt( C, B ) -> A
*
* author: May/2002 - Hector Correa
* updated:
*XorIt( "mypassword", "akeytoencrypt" ) -> "someencryptedvalue"
*XorIt( "someencryptedvalue", "akeytoencrypt" ) -> "mypassword

CLEAR
*1st time
lcpassword=""
lcpassword="x8RockAndRolL1230x9"
encrypted1=XorIt(lcpassword,'password')
? "1st try"
?
? "Encrypted password: "+encrypted1
unencrypted1=XorIt(encrypted1,'password')
? "unencrypted password: "+ unencrypted1
*2nd time
lcname=""
lcname="Tracy C. Holzer"
encrypted2=XorIt(lcname,'name')
?
?"2nd try"
?
?"Encrypted Name: "+encrypted2
unencrypted2=XorIt(encrypted2,'name')
?"Unencrypted name: "+unencrypted2
unencrypted1=XorIt(encrypted1,'password')
?"Unencrypted password: "+unencrypted1

Function XorIt( cString, cMask )

	if empty( cString )
		return ""
	endif

	if empty( cMask )
		return ""
	endif

	cRetVal = ""
	nlength = LEN( cString )
	cMask = padr( cMask, nlength, "#" )

	FOR i=1 TO nlength
		nChar = ASC( SUBSTR( cString, i, 1 ) )
		nKeyChar = ASC( SUBSTR( cMask, i, 1 ) )
		nNewChar = BITXOR( nChar, nKeyChar )
		cRetVal = cRetVal + CHR( nNewChar )
	NEXT

RETURN cRetVal
Is something in the buffer not getting released before sending anything to the screen as output?

>XOR operation is an interesting operation for creating encryption routines. The cool idea in XOR is that the same key can be used to encrypt and descrypt the value. For example:
>
>XorIt( "mypassword", "akeytoencrypt" ) -> "someencryptedvalue"
>
>then
>
>XorIt( "someencryptedvalue", "akeytoencrypt" ) -> "mypassword
>
>This is useful if for some reason you store the password in a text file or other easy to read type of file. In that case, you can store "someencryptedvalue" and then use that value to obtain the actual password value.
>
>
>* description: Encrypts cString with value passed in cMask
>* using Bit XOR operation.
>*
>* Bit XOR operation works like this:
>* XorIt( A, B ) -> C
>* XorIt( C, B ) -> A
>*
>* author: May/2002 - Hector Correa
>* updated:
>Function XorIt( cString, cMask )
>
>	if empty( cString )
>		return ""
>	endif
>
>	if empty( cMask )
>		return ""
>	endif
>
>	cRetVal = ""
>	nLenght = LEN( cString )
>	cMask = padr( cMask, nLenght, "#" )
>
>	FOR i=1 TO nLenght
>		nChar = ASC( SUBSTR( cString, i, 1 ) )
>		nKeyChar = ASC( SUBSTR( cMask, i, 1 ) )
>		nNewChar = BITXOR( nChar, nKeyChar )
>		cRetVal = cRetVal + CHR( nNewChar )
>	NEXT
>
>RETURN cRetVal
>
>
>
>
>>I've created a registration KEY to protect my software
>>
>> As below for every name it will be key to allow
>> the software to work
>>
>> Name: JOHN MEDEIROS
>> Key: TFGC 1234ER96
>>
>> I am using STRAN funcition to create this
>> However I think it's very obvious as every
>> letter corresponds to another letter
>>
>> Anybody has a better suggestions to create a more
>> complex hey ?
>>
>> Moisse
>>
>>
>>
>>
>>
>>
>>
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform