I am creating a little application in which I create a SHA1 hash with php and use the chunk_split
function in php to insert a "|" every x characters.
Is there something similar? Or how would one split the string and insert a character there?
PHP Code:
substr(strtoupper(chunk_split(sha1("this is my super secure test application"), 5, "-")), 0, 29);
How can I do this with Qt?
You could write something like this:
#include <QString>
#include <QDebug>
int main()
{
const int step = 3;
const char mychar = 'x';
QString myString = "FooBarBaz";
for (int i = step; i <= myString.size(); i+=step+1)
myString.insert(i, mychar);
qDebug() << myString;
return 0;
}
TEMPLATE = app
TARGET = main
QT = core
SOURCES += main.cpp
qmake && make && ./main
"FooxBarxBazx"
See the documentation of the insert method in here.