you must code your string. The simplest way is to use Base64 encoding.
QByteArray has 2 methods:
::toBase64(..) // use function to get the byte array to be inserted in source code.
::fromBase64(..) // use function to decode the string in your application code
run this part of code during code editing and replace the result in the source code:
QByteArray str
("secret");
// the variable you want to hidden qDebug() << str.data() << "-->" << str.toBase64(); // the encoded variable in Base64
QByteArray str("secret"); // the variable you want to hidden
qDebug() << str.data() << "-->" << str.toBase64(); // the encoded variable in Base64
To copy to clipboard, switch view to plain text mode
in your application:
// declare and initialize your variable
QByteArray encoded
("c2VjcmV0");
// this is your encoded string // use your variable
QByteArray decoded
= QByteArray::fromBase64( encoded
);
// this is your decoded string as QByteArray qDebug() << encoded.data() << "-->" << decoded.data();
// declare and initialize your variable
QByteArray encoded("c2VjcmV0"); // this is your encoded string
// use your variable
QByteArray decoded = QByteArray::fromBase64( encoded ); // this is your decoded string as QByteArray
QString decodedString = QString( QByteArray::fromBase64( encoded )); // alternatively as QString
qDebug() << encoded.data() << "-->" << decoded.data();
To copy to clipboard, switch view to plain text mode
the debug output is:
secret --> "c2VjcmV0"
c2VjcmV0 --> secret
Bookmarks