QString s = url.toString(); QByteArray h = QCryptographicHash::hash(s.toUtf8(), QCryptographicHash::Sha1); QString ret; const char *data = h.constData(); for (int i = 0; i < h.size(); i++) { char buf[3]; sprintf(buf, "%02x", (unsigned char)data[i]); ret += buf; } return ret;