Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Registration KEY
Message
 
À
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:
00766044
Vues:
35
I guess it is doing this because some of the encrypted characters are ASCII values less than 32 and the "?" does not know how to print them.

This could cause problems if you send encrypted value to something that does not know how to handle ASCII values less than 32. For example, to SQL Server. So, what I do is that I store the encrypted value (like in a text/binary file) and then decrypt it before sending it to SQL Server.
? "1st try"
?
? "Encrypted password: "+encrypted1
? "ASCII values:"
for i=1 to len(encrypted1)
	?? asc(substr(encrypted1,i,1)),","
next
>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
>>>
>>>
>>>
>>>
>>>
>>>
>>>
Hector Correa
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform