Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Encrypting a table field
Message
De
10/01/2000 23:02:12
 
 
À
10/01/2000 14:41:29
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00315680
Message ID:
00315961
Vues:
30
>I am creating a program that requires one of the field to be encrypted on the sql server. I need to be able to store weither or not the program has been registered and I don't want the user to beable to just open the table and see what's needed to register the program. Is there a way to encrypt a field in a table. Is there some trick that I could use to do this.
>

A number of simple to implement, fairly fast mechanisms exist; the one I'm fondest of is a simple XOR of each character with another character. It's nice because the encrypt and decrypt routines are identical. Something like:
FUNCTION CryptXOR
LPARAMETERS tcStringToEncrypt, tcKey
LOCAL nPtr, cResult, nKeyLength, nChar
cResult = ''
nKeyLength = LEN(tcKey)
FOR nPtr = 1 TO LEN(tcStringToEncrypt)
   nChar = ASC(SUBST(tcStringToEncrypt,nPtr,1))
   cResult = cResult + CHR( BITXOR(nChar,ASC(SUBST(tcKey,1 + (nPtr % nKeyLength),1))))
ENDFOR
RETURN cResult
You need to exercise a bit of care in selecting values for the key. It's not terribly secure, but it's easy, free, and self-extracting, IOW:

CryptXOR(CryptXOR('abcdefg','MyKey'),'MyKey')

will give back the unencrypted value.
EMail: EdR@edrauh.com
"See, the sun is going down..."
"No, the horizon is moving up!"
- Firesign Theater


NT and Win2K FAQ .. cWashington WSH/ADSI/WMI site
MS WSH site ........... WSH FAQ Site
Wrox Press .............. Win32 Scripting Journal
eSolutions Services, LLC

The Surgeon General has determined that prolonged exposure to the Windows Script Host may be addictive to laboratory mice and codemonkeys
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform