Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Converting VFP encryption functions to .NET
Message
From
29/01/2007 19:11:29
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
28/01/2007 12:09:21
General information
Forum:
ASP.NET
Category:
Coding, syntax and commands
Environment versions
Environment:
VB 8.0
OS:
Windows XP SP2
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01189912
Message ID:
01190329
Views:
14
>In my framework, I already have some encryption classes. But, for a while, I need to be able to read encrypted data that has been done in VFP code, which is not using the same algorythm. Basically, I am trying to know if I could obtain a VB.NET equivalent of that code:
>
>
>* Text decryption
>* expC1 Text to decrypt
>* expC2 Encryption key
>FUNCTION Uncrypt
>LPARAMETERS tcTxt,tcKey
>LOCAL lnPKey,lnLenKey,lnLenTxt,lcKey,lcRes,lnNPos,lnByte,lnAscKey,;
> lnSumAsc,lnPosIgnore,lnKeySXOR,lnKeyLXOR,lnKeyBXOR,lcKey
>
>lcKey=tcKey
>STORE LEN(lcKey) TO lnLenKey
>STORE LEN(tcTxt) TO lnLenTxt
>
>LOCAL ARRAY laSKey[lnLenTxt,2]
>
>STORE 0 TO lnSumAsc, lnKeyBXOR
>FOR lnPKey = 1 TO lnLenKey
>   STORE lnSumAsc + ASC(SUBSTR(lcKey, lnPKey, 1))  TO lnSumAsc
>NEXT
>FOR lnPKey = 1 TO lnLenTxt
>   STORE SUBSTR(lcKey, (lnPKey % lnLenKey)+1, 1)                     TO laSKey[lnPKey,1]
>   STORE ASC(laSKey[lnPKey,1])                                           TO lnAscKey
>   STORE BITXOR(lnKeyBXOR,BITAND(255,BITLSHIFT(lnAscKey, lnPKey%5))) TO lnKeyBXOR
>   STORE lnPKey                                                          TO laSKey[lnPKey,2]
>NEXT
>
>STORE lnSumAsc % 3                           TO lnPosIgnore
>STORE BITRSHIFT(lnSumAsc,lnLenKey%3) % 256 TO lnKeySXOR
>STORE lnLenKey % 256                         TO lnKeyLXOR
>
>=ASORT(laSKey)
>
>STORE SPACE(lnLenTxt) TO lcRes
>FOR lnPos = 1 TO lnLenTxt
>   STORE laSKey[lnPos,2]                            TO lnNPos
>   STORE ASC(SUBSTR(tcTxt,lnPos,1))               TO lnByte
>   STORE BITXOR(lnByte, ASC(laSKey[M.lnPos,1]))     TO lnByte
>   STORE BITXOR(lnByte, lnKeyBXOR)                TO lnByte
>   STORE BITXOR(lnByte, lnKeyLXOR)                TO lnByte
>   STORE BITXOR(lnByte, lnKeySXOR)                TO lnByte
>   STORE BITXOR(lnByte, 2^(1+lnNPos%4+lnPos%2)) TO lnByte
>   STORE BITXOR(lnByte, 2^(1+lnPos%4))            TO lnByte
>   STORE STUFF(lcRes, lnNPos, 1, CHR(lnByte))   TO lcRes
>NEXT
>RETURN lcRes
>
Michel,
You can come close but can't get the same exact result I think. Because you're using asort() which works on multidimensional arrays unpredictably (your VFP code even have a chance to return different results from version to version).
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform