Results 1 to 2 of 2

Thread: Wiping sensitive data in QML

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Mar 2012
    Qt products
    Unix/X11 Windows

    Default Wiping sensitive data in QML


    I am looking for a way to wipe properties of objects once the property is not needed any more. Reassigning unfortunately doesn't work (value is changed, but you can still find original values in memory, until the area is re-used by something else). Basically I'm looking for an equivalent of QByteArray::fill, but as I can't get to the properties themselves (only the copies), original values still dangle around the memory. Any ideas (on C++ or QML side) would be very welcome.
    Last edited by Buldozer; 6th November 2019 at 17:15.

  2. #2
    Join Date
    Mar 2012
    Qt products
    Unix/X11 Windows

    Default Re: Wiping sensitive data in QML

    To answer my own question (and help anyone else looking for an (ugly) solution to the same problem):

    In the end the problem actually turned out to be - how to modify QVariant string data directly. Turns out the biggest problem was in-place rewriting of QString data. I came up with a solution (though I don't really like it and would prefer something cleaner):

    Qt Code:
    1. Q_INVOKABLE void wipe(QVariant value)
    2. {
    3. void *valuePtr = value.d.is_shared ?>ptr : static_cast<void *>(&(;
    4. if ((value.type() == QMetaType::QString) && valuePtr) {
    5. QString *text = reinterpret_cast<QString *>(valuePtr);
    6. QChar* txtPtr = const_cast<QChar*>(text->constData()); //yes, const_cast constData(), as data() creates a modifiable copy
    7. for (int x = 0; x < text->size(); x++)
    8. *(txtPtr++) = QChar(0);
    9. }
    10. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QTableWidget case sensitive sort
    By Raccoon29 in forum Newbie
    Replies: 20
    Last Post: 15th December 2015, 08:18
  2. URGENT time sensitive
    By schumura in forum Jobs
    Replies: 0
    Last Post: 27th July 2011, 13:54
  3. Context sensitive help on OS X
    By wconstan in forum Newbie
    Replies: 1
    Last Post: 8th January 2010, 13:14
  4. Can executable-name be case-in-sensitive in Linux ...??
    By joseph in forum Installation and Deployment
    Replies: 1
    Last Post: 3rd June 2008, 08:27
  5. Context sensitive help
    By jpn in forum Qt Programming
    Replies: 4
    Last Post: 10th February 2007, 00:27


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.