LPARAMETERS cPassword AS MEMO IF EMPTY(M.cPassword) cPassword = "myPassword" ENDIF LOCAL ckZip AS Chilkat_v9_5_0.ChilkatZip LOCAL ckUnzip AS Chilkat_v9_5_0.ChilkatZip LOCAL ckZipEntry AS Chilkat_v9_5_0.ChilkatZipEntry LOCAL MemZip AS Variant LOCAL MemUnzip AS String m.ckZip = CREATEOBJECT("Chilkat_9_5_0.Zip") *!* * set encryption mode to AES m.ckZip.Encryption = 4 *!* * set key length m.ckZip.EncryptKeyLength = 256 * and the key itself m.ckZip.EncryptPassword = cPassword * create a dummy Zip file IF m.ckZip.NewZip("c:/hroffice/dummy.zip") != 1 MESSAGEBOX(m.ckZip.LastErrorText) RETURN ENDIF * add some data to the Zip object m.ckZip.AppendString2("entry.txt", "my AES protected string", "utf-8") * and write the object to memory m.MemZip = m.ckZip.WriteToMemory() ** DG extra >> save the zip into the physical file resource loFac = CREATEOBJECT("Chilkat_9_5_0.FileAccess") IF m.loFac.WriteEntireFile("test.zip",M.MemZip) <> 1 MESSAGEBOX(m.ckZip.LastErrorText) RETURN ENDIF RETURNCode for feeding a VFP string from the AES-256 zipped resource:
LPARAMETERS cPassword AS MEMO IF EMPTY(M.cPassword) cPassword = "myPassword" ENDIF LOCAL ckZip AS Chilkat_v9_5_0.ChilkatZip LOCAL ckUnzip AS Chilkat_v9_5_0.ChilkatZip LOCAL ckZipEntry AS Chilkat_v9_5_0.ChilkatZipEntry LOCAL MemZip AS Variant LOCAL MemUnzip AS String m.ckUnzip = CREATEOBJECT("Chilkat_9_5_0.Zip") m.ckUnzip.Encryption = 4 m.ckUnzip.EncryptKeyLength = 256 m.ckUnzip.DecryptPassword = cPassword m.ckUnzip.OpenZip("test.zip") IF (m.ckUnzip.LastMethodSuccess=0) RETURN ENDIF loEntry = m.ckUnzip.FirstMatchingEntry("entry.txt") lcStrCsv = M.loEntry.UnzipToString(0,"utf-8") IF EMPTY(lcStrCsv) MESSAGEBOX("password is incorrect!") ELSE MESSAGEBOX(lcStrCsv) ENDIF RETURNThanks for feeding me with great startup material on this large, thus pretty intimidating, library. Looking forward to using more of the Chilkat suite!