Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Pseudo 16-bit encryption VFP8/FPD26 Shared Table
Message
From
18/03/2003 10:02:29
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Pseudo 16-bit encryption VFP8/FPD26 Shared Table
Miscellaneous
Thread ID:
00767011
Message ID:
00767011
Views:
47
I have free tables (codepage 537) that are shared by an OLD FPD26 app and a newer VFP7/8 app. Normally, this is not an issue. However, in one instance the values in the fields are pseudo encrypted in FPD26 and unencrypted in FPD26 to read the values in the fields. Of course, if I try to run the same utility in VFP7, it cannot unencrypt the values. Does anyone have any ideas?

TIA,

Here is the code that unencrypts the values in FPD26:
*******************************************
* Psuedo 16bit data encryption algorithm.
*
* Purpose:Encrypts string data.
* Useage: <str1>=wordhide(<str2>)
* Convert back: <str3>=wordhide(<str1>)
*
*******************************************

PARAMETER xstr

PRIVATE i,j,ret,xval,temp
newstr = xstr
IF _xldata
	newstr = ""
	* Get pairs of characters from the string
	FOR k = 1 TO LEN(xstr) STEP 2
		v3=ASC(SUBSTR(xstr,k+1,1)) + ;
				ASC(SUBSTR(xstr,k,1)) * 256

		* Don't encrypt 2 spaces together.
		IF v3=8224
			v4=v3
		ELSE
			v4=messybits(V3)
		ENDIF
		v1 = 0
		v2 = 0
		IF v4 >= 256
			v1 = INT(v4 / 256)
			v4 = v4 - (v1 * 256)
		ENDIF
		v2 = int(v4)
		newstr=newstr+CHR(V1)+CHR(V2)
	ENDFOR
ENDIF
?newstr

RETURN newstr

*****************************
PROCEDURE messybits
*****************************

* This routine takes a 16bit number (0 - 65535), converts it to BINARY and
* then rearranges the BITS for data encryption.

PARAMETER dword
PRIVATE _i,_j,retval,_xval,temp

retval = ""
FOR _j = 15 to 0 STEP -1
	if dword >= 2^_j
		retval=retval+"1"
		dword = dword - 2^_j
	else
		retval=retval+"0"
	endif
ENDFOR

* Move through 16 bits, get every 4th bit and make new binary number
temp = ""
FOR _i = 1 TO 4
	FOR _j = 0 to 3
		temp = temp + SUBSTR(retval,_i+(_j*4),1)
	ENDFOR
ENDFOR

retval=temp

* Convert the BINARY number back to decimal and, just
* for fun, flip the BINARY number backwards as we do it.

_xval=0
FOR _j = 1 to LEN(retval)
	IF SUBSTR(retval,_j,1) = "1"
		_xval = _xval + 2^(_j-1)
	ENDIF
ENDFOR
RETURN _xval
.·*´¨)
.·`TCH
(..·*

010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"
Next
Reply
Map
View

Click here to load this message in the networking platform