Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Encryption
Message
From
06/01/2003 10:40:31
 
 
To
06/01/2003 09:12:36
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Miscellaneous
Thread ID:
00738349
Message ID:
00738371
Views:
14
This may be too simple, but I'll show you anyway...


*****************************************************************************
* Name : Encrypt
* Description: Encrypts or decrypts a given string
* Parameters : tcIn - character string to convert
* tlDecrypt - whether this function should decrypt the given string
* Returns : Character string converted according to the encrypt/decrypte algorithm
*****************************************************************************
FUNCTION ENCRYPT
LPARAMETER tcIn, tlDecrypt
LOCAL lcKey, lnLoop, lcOut, lnPosition, lcChar, lnAscii1, lnAscii2, lnAdjustment

IF PARAMETERS() < 1 OR EMPTY(tcIn)
RETURN ""
ENDIF

lcKey = "BlZ1@d0fDh"
lcOut = ""
FOR lnLoop = 1 TO LEN(TRIM(tcIn))
lnPosition = MOD(lnLoop-1, LEN(lcKey)) + 1

lnAscii = ASC(SUBSTR(tcIn, lnLoop, 1)) - 32 - 1

lnAdjustment = (ASC(SUBSTR(lcKey, lnPosition, 1)) + lnLoop) * IIF(tlDecrypt,-1,1)
lnAsciiNew = lnAscii + lnAdjustment
lcChar = CHR(MOD(lnAsciiNew, 94) + 32 + 1)
lcOut = lcOut + lcChar
ENDFOR
RETURN lcOut
ENDFUNC
Gordon de Rouyan
DC&G Consulting
Edmonton, Alberta
Email: derouyag@shaw.ca
Previous
Reply
Map
View

Click here to load this message in the networking platform