Hello,
I am working on a multiplatform app where we need to retrieve credentials installed in the machine keychain.
Using secret-tools on Linux and security on macOs works fine. I can add the values to the keychain and retrieve them using qtkeychain.
But on Windows (11 Enterprise), when I use the cmdkey command cmdkey /generic:"mysecretkey" /user:"any" /pass:test, I am able to retrieve the data with a ReadPasswordJob, but calling textData() returns a QString with the wrong format "t\u0000e\u0000s\u0000t\u0000"
If I use a QStringDecoder with Utf16LE on the binary data, it works properly
QStringDecoder decoder(QStringDecoder::Utf16LE);
qInfo() << decoder.decode(pw_read_job->binaryData());
But doing so, I lose the compatibility to write data using the qtkeychain setTextData() API and read it through the same code.
I guess I can always rely on setBinaryData() specifically for Windows, but I wonder if the API should be more consistent across platform and encode the password in utf16 for Windows since it is what the Windows Keychain CLI supports.
Hello,
I am working on a multiplatform app where we need to retrieve credentials installed in the machine keychain.
Using secret-tools on Linux and security on macOs works fine. I can add the values to the keychain and retrieve them using qtkeychain.
But on Windows (11 Enterprise), when I use the cmdkey command
cmdkey /generic:"mysecretkey" /user:"any" /pass:test, I am able to retrieve the data with a ReadPasswordJob, but calling textData() returns a QString with the wrong format "t\u0000e\u0000s\u0000t\u0000"If I use a QStringDecoder with Utf16LE on the binary data, it works properly
But doing so, I lose the compatibility to write data using the qtkeychain setTextData() API and read it through the same code.
I guess I can always rely on setBinaryData() specifically for Windows, but I wonder if the API should be more consistent across platform and encode the password in utf16 for Windows since it is what the Windows Keychain CLI supports.