Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
_crypt between vfp7, vfp8, and vfp9
Message
From
25/10/2005 09:43:20
 
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Miscellaneous
Thread ID:
01061732
Message ID:
01061841
Views:
13
This works for me in VFP9, Windows XP SP2. When I compare it to the encrypted version of the same file encrypted in vfp7, it matches. I must be missing something?
SET SAFETY OFF
lcstartfile = "myfile.txt"
IF FILE(lcstartfile)
   DELETE FILE (lcstartfile)
ENDIF

lcstartstring = REPLICATE("1234567890-=\~!@#$%^&*()_+|abcdefghijklmnopqrstuvwxyz,./<>?[]{}"+CHR(13),2000)
STRTOFILE(lcstartstring,"myfile.txt")

loCrypt = NEWOBJECT("_CryptApi",HOME()+"FFC\_Crypt.vcx")
IF FILE(lcstartfile)
   MODIFY COMMAND (lcstartfile)

   IF MESSAGEBOX('Encrypt File?',1+32+4096,'Encrypt') = 1
      =TestCrypt(.F.,lcstartfile)
      MODIFY COMMAND (lcstartfile)
   ENDIF
   IF MESSAGEBOX('Decrypt File?',1+32+4096,'Decrypt') = 1
      =TestCrypt(.T.,lcstartfile)
      MODIFY COMMAND (lcstartfile)
   ENDIF
ENDIF
IF FILE(lcstartfile)
   DELETE FILE (lcstartfile)
ENDIF
RETURN

FUNCTION TestCrypt
LPARAMETERS plReverse, pcfile

IF TYPE('pcfile') <> "C" .OR. !FILE(pcfile)
   RETURN .F.
ENDIF

IF plReverse
   lcString = FILETOSTR(pcfile)
   lcDecrypted = ''
   ? loCrypt.DecryptSessionBlockString(lcString, "x", @lcDecrypted )
   STRTOFILE(m.lcDecrypted,pcfile)
ELSE
   lcEncrypted = ""
   lcString = FILETOSTR(pcfile)
   ? loCrypt.EncryptSessionBlockString( lcString, "x", @lcEncrypted )
   STRTOFILE(m.lcEncrypted,pcfile)
ENDIF
RETURN
.·*´¨)
.·`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"
Previous
Reply
Map
View

Click here to load this message in the networking platform