Qcad 3.16.3: QCryptographicHash return wrong result

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
duccoder
Active Member
Posts: 30
Joined: Thu Jun 25, 2015 10:11 am

Qcad 3.16.3: QCryptographicHash return wrong result

Post by duccoder » Mon Jan 02, 2017 5:26 am

Hi.
I have the code to generate hash like below:

Code: Select all

var str = "fooBar";
var hash = QCryptographicHash.hash(new QByteArray(str), QCryptographicHash.Md5).toHex();
print(hash);
When I run autostart above with qcad 3.15.5, it work well, but when run with qcad 3.16.3 it always return same result while I change str value (I've try use `Md5`, `sha1`,... but they always return wrong value).

So it's bug from qt5?

User avatar
andrew
Site Admin
Posts: 9061
Joined: Fri Mar 30, 2007 6:07 am

Re: Qcad 3.16.3: QCryptographicHash return wrong result

Post by andrew » Mon Jan 02, 2017 11:50 am

Looks like the QByteArray constructor is broken in the Qt 5 script bindings. This should be fixed for the next release.

As a workaround:

Code: Select all

var str = "fooBar";
var ba = new QByteArray();
ba.append(str);
var hash = QCryptographicHash.hash(ba, QCryptographicHash.Md5).toHex();
print(hash);

duccoder
Active Member
Posts: 30
Joined: Thu Jun 25, 2015 10:11 am

Re: Qcad 3.16.3: QCryptographicHash return wrong result

Post by duccoder » Tue Jan 03, 2017 2:22 am

I see. Thanks for your answer :D

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”