Archived Forum Post

Index of archived forum posts


Zip password is strange in Mac OS X

Jun 10 '16 at 14:35

ifdef Q_OS_WIN // Windows

define UUU(x) (LPCWSTR)x.unicode()

define SSS(x) QString((QChar*)x)

else // Mac and Linux

define UUU(x) (wchar_t*)x.toStdWString().c_str()

define SSS(x) QString::fromWCharArray(x)


DOCUMENT TO QString::toStdWString()

MyTool.h: CkZipW* m_zip;

void MyTool::Mytool { m_zip = new CkZipW(); bool success = m_zip->UnlockComponent(ZIP_CODE); }

bool MyTool::ZipAES(QString strSrcFile, QString strPasswd) { const QFileInfo fi = QFileInfo(strSrcFile); QString strFileName = fi.fileName()+".zip"; QString strDestFile = "/dev/"+strFileName; // or "c:/dev/"

bool success1 = m_zip->NewZip(UUU(strDestFile));


bool success2 = m_zip->AppendOneFileOrDir(UUU(strSrcFile), false);
if (success2 != true) {
    qDebug() << strSrcFile;

bool success3 = m_zip->WriteZipAndClose();

return success1 && success2 && success3;


I Use MyTool tool; tool.ZipAES("c:/test.txt", "00000");

QString is always Unicode with 16 bit in all platforms. But Chilkat always use wchar_t which has different bits. So I have to transform QString to wchar_t.

The above code works well in windows. And it works well also in Mac (Zip and UnZip). But in Mac, the real password is not 00000 (I copy the zip file to windows and try to use winrar to decompress it, but it fail), it is other something. Windows has not this problem. Could you tell me what's wrong with my code above and what is the real password final if possible. Thanks!

I use C++/Mingw/Clang, CkZipW in Windows, CkZipW in Mac , Qt5.6.

Accepted Answer

Here are the MinGW builds with the Ck*U classes (such as CkZipU)

Download URL:
Download URL:
Download URL:
Download URL:
Download URL:
Download URL:
Download URL:
Download URL:
Download URL:


Thanks, I'm looking into it.. -Matt


Please try this new build for Mac OS X C++:

This build adds a full set of C++ classes that end in "U" instead of "W". For example: the class CkZipU where the header file is CkZipU.h The "U" classes use "uint16_t " instead of "wchar_t ". These classes have existed for a long time internal to Chilkat, but have never been exposed. From this point onward, starting with the next version, they will be included in the Linux, Mac OS X, and Mingw libs. Everything's the same as the wchar_t classes, except the class name ends in "U" and "uint16_t" is used instead of "wchar_t".

I'm doing the Mingw builds now, and will post when ready.

Also, these pre-release include the CkRestU class, and all other classes marked as "Coming soon".


OK, I tested "U" in Mac, now the password is correct "00000".

But I don't understand, why not correct this problem in W version. Because every function works well as I expect, except the function put_EncryptPassword.Otherwise nobody knows the correct password, event it can still work.

Let me continue to test in Windows with U version, so I can keep always the unique code in all platforms.


Any news for this bug in "W" version? And the problem of callback of SFTP? I am eager to wait for your corrections to these two bugs.