>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.