Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Chilkat activeX: decoding AND encoding AES-256 zip
Message
From
10/11/2020 07:01:54
Antonio Lopes (Online)
BookMARC
Coimbra, Portugal
 
 
To
10/11/2020 04:14:40
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01677081
Message ID:
01677083
Views:
112
This message has been marked as the solution to the initial question of the thread.
Daniel,

Doing this with Chilkat:
* assume Chilkat is globally unblocked

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 = 0h000102030405060708090a0b0c0d0e0f1011121314151601718191a1b1c1d1e1f


* create a dummy Zip file
IF m.ckZip.NewZip("dummy.zip") != 1
	MESSAGEBOX(m.ckZip.LastErrorText)
	RETURN
ENDIF

* add some data to the Zip object
m.ckZip.AppendString2("entry.txt", "Daniel Gadenne", "utf-8")

* and write the object to memory
m.MemZip = m.ckZip.WriteToMemory()

* build the cursor to store the data
CREATE CURSOR ProtectedInfo (id_info Int Autoinc, zipped_info Blob)

INSERT INTO ProtectedInfo (zipped_info) VALUES (m.MemZip)

BROWSE

* zipped_info displays:
* 504B030414000100630054676A51000000002C0000000E00000009000B00656E74
* 72792E747874019907000200414503080080F0BA0228E19CAC21E55339A7F42DBD
* 3ACDEB32214D881991C41C6591EA8D18F73390FE707334467E16C721504B010214
* 0014000100630054676A51000000002C0000000E00000009000B00000000000100
* 8000000000000000656E7472792E7478740199070002004145030800504B050600
* 00000001000100420000005E0000000000

* destroy the zip, just to make sure everything is lost before unzipping
RELEASE m.ckZip

* now, to unzip it:

m.ckUnzip = CREATEOBJECT("Chilkat_9_5_0.Zip")

* config the encryption process (as above)

m.ckUnzip.Encryption = 4
m.ckUnzip.EncryptKeyLength = 256
m.ckUnzip.EncryptPassword = 0h000102030405060708090a0b0c0d0e0f1011121314151601718191a1b1c1d1e1f


* get zip data from the cursor
m.ckUnzip.OpenFromMemory(ProtectedInfo.zipped_info)

* fetch the entry
m.ckZipEntry = m.ckUnzip.GetEntryByName("entry.txt")

* and unzip it into a string
m.MemUnzip = m.ckZipEntry.UnzipToString(0, "utf-8")

* display the zipped / encrypted and the unzipped / decrypted data
MESSAGEBOX(ProtectedInfo.zipped_info)
MESSAGEBOX(m.MemUnzip)  && displays "Daniel Gadenne"
>Hi all of you,
>
>Per default, our VFP applications save most of its information in plain text format. Easy read and easy write in fox!
>
>We are contemplating offering an optional "AES-encryption-zip" file format as an alternative and I was giving a look at the "Chilkat suite" activeX in this respect.
>
>My question(s) is(are) pretty simple :
>- can Chilkat easily transform a VFP string into an AES zipped file resource?
>- can you unzip this zip file straight back into an un-encrypted VFP string?
>
>I expect the answers to be yes. But I am concerned about the process to be fully and safely "in-memory". Should we decide to offer encryption, we certainly NOT to hear that the process requires building un-encrypted temp files as intermediate steps!
>
>Kind regard for any feedback on this issue and, at large, Chilkat suite usability from VFP. Looks like some sort of win32 "swiss knife" for the VFP die-hard such as those on this forum!
>
>Cheers, Daniel
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform