Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Decryption in Fpw and Vfp
Message
From
20/11/2009 08:43:32
 
General information
Forum:
Visual FoxPro
Category:
FoxPro 2.x
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP SP2
Network:
Windows 2008 Server
Database:
MySQL
Miscellaneous
Thread ID:
01435409
Message ID:
01435769
Views:
52
Thank you so much Sergey, this is so great, I haven't expected this.

>Hi Christian,
>
>See if following modified code works the same way as Fox 2.x FLL
>
>
>
>*
>* Parameters:
>*   tcStr      - string to encrypt/decrypt
>*   tcPassword - password to use for encryption/decryption 
>*
>*----------cipher.prg----------
>FUNCTION CipherOld 
>LPARAMETERS tcStr, tcPassword
> 
>#define   PW_MIN_LEN   3		&&  /* min  number of characters in the password */
>***#define   PW_MIN_NUM   1000		&&  /* min value for the password seed */
>#define   PW_MIN_NUM   10000000  		&&  /* min value for the password seed */
>   
>LOCAL lnStrLen, lnPassLen, lnPassNum, laPassword[1,2], lcPassword
>LOCAL lcStrOut, lnPassPos, lnNum01, lcStrOut, lnInPos, lnPassPos
> 
>IF TYPE("tcStr") <> "C" ;
>		OR TYPE("tcPassword") <> "C" ;
>		OR LEN(tcPassword) < PW_MIN_LEN
>	Error 11
>ENDIF
> 
>lnStrLen = LEN(tcStr)
> 
>lcPassword = tcPassword 
>***lcPassword = tcPassword + CHR(0)
>lnPassLen = LEN(lcPassword)
>DIMENSION laPassword[lnPassLen+1,2]
>FOR lnPassPos=1 TO lnPassLen
>	laPassword[lnPassPos,2] = SUBSTR(lcPassword,lnPassPos,1)
>	laPassword[lnPassPos,1] = ASC(laPassword[lnPassPos,2])
>ENDFOR
> 
>* Get seed value
>lnPassNum = INT((((CipherGetPnum(lcPassword)/997) - 1) % 254) + 1 )
>lcStrOut = ""
>lnPassPos = 1
> 
>* Encode/decode each character
>FOR lnInPos=0 TO lnStrLen-1
>	* Get new seed value
>	lnNum01 = (( lnPassNum + (lnInPos - lnStrLen)) - 1)
>	lnPassNum = (ABS(lnNum01) % 254) * SIGN(lnNum01) + 1
>	* Encode current character
>	lnByte = BITXOR( ASC(SUBSTR(tcStr,lnInPos+1,1)), ;
>		BITXOR(lnPassNum, laPassword[lnPassPos,1]))
>	* Convert signed value to unsigned, if necessary
>	lnByte = BITAND(lnByte, 0xFF)
>	* If result is zero, use current character
>	lcStrOut = lcStrOut + IIF(lnByte = 0, SUBSTR(tcStr,lnInPos+1,1), CHR(lnByte))
>	* Advance to the next password character
>	***lnPassPos = IIF( lnPassPos => lnPassLen, 1, lnPassPos + 1)
>ENDFOR
> 
>RETURN lcStrOut
> 
>* Returns a seed value based on the string passed as parameter
>FUNCTION CipherGetPnum(tcStr)
>LOCAL liRet, lnPos
>liRet = 1
>FOR lnPos=0 TO LEN(tcStr ) - 1
>	liRet = liRet + ASC(SUBSTR(tcStr,lnPos+1,1)) + lnPos
>ENDFOR
>DO WHILE (liRet < PW_MIN_NUM)
>	liRet = BITLSHIFT(liRet,1)
>ENDDO
>RETURN liRet
>
>
>>Thanks for your comment, that clears up the problem that I'm having. Only that I cannot re-encrypt the passwords, because I cannot do any changes in the FPW code, because that would break a lot of other places.
>>
>>The only workaround I was thinking about was to use FPW2.6 to do the decryption. Or perhaps better would be if I find somewhere the old Cipher.fll encryption algorithm and code it in VFP?
>>
>>The password encryption strength is not a big issue, because it's anyway open FoxPro tables.
Christian Isberner
Software Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform