Esempio n. 1
0
    def __init__(self, raw):
        self.files = []
        self.zip = chilkat.CkZip()

        self.zip.UnlockComponent(CHILKAT_KEY)

        self.zip.OpenFromMemory(raw, len(raw))

        filename = chilkat.CkString()
        e = self.zip.FirstEntry()
        while e != None:
            e.get_FileName(filename)
            self.files.append(filename.getString())
            e = e.NextEntry()
Esempio n. 2
0
    def delete(self, patterns):
        el = []

        filename = chilkat.CkString()
        e = self.zip.FirstEntry()
        while e != None:
            e.get_FileName(filename)

            if re.match(patterns, filename.getString()) != None:
                el.append(e)
            e = e.NextEntry()

        for i in el:
            self.zip.DeleteEntry(i)
Esempio n. 3
0
def blowfishECB(crypt, key, clearBytes, expectedAnswer):

    # Set the secret key
    crypt.SetEncodedKey(key, 'hex')

    # Get the unencrypted data as binary data.
    unencryptedData = chilkat.CkByteData()
    crypt.Decode(clearBytes, 'hex', unencryptedData)

    encryptedHexString = chilkat.CkString()
    crypt.EncryptBytesENC(unencryptedData, encryptedHexString)

    # Chilkat padded to a multiple of 16 bytes, so we discard the padding.
    # (In this case, Chilkat added 8 NULL bytes to the original 8 bytes of data,
    # so we drop 16 characters - the hex encoding uses 2 characters per byte.)
    encryptedHexString.shorten(16)

    # Return a string that will be added to our output for visual verification.
    return encryptedHexString.getString() + ' should equal ' + expectedAnswer