Fix signature in Qobuz stream url request

Fixes #267
This commit is contained in:
Jonas Kvinge 2019-09-23 19:18:12 +02:00
parent 76b4a6585e
commit 055516312a
1 changed files with 9 additions and 1 deletions

View File

@ -110,6 +110,14 @@ void QobuzStreamURLRequest::GetStreamURL() {
reply_->deleteLater();
}
QByteArray appid = app_id().toUtf8();
QByteArray secret_decoded = QByteArray::fromBase64(app_secret().toUtf8());
QString secret;
for (int x = 0, y = 0; x < secret_decoded.length(); ++x , ++y) {
if (y == appid.length()) y = 0;
secret.append(QChar(secret_decoded[x] ^ appid[y]));
}
quint64 timestamp = QDateTime::currentDateTime().toTime_t();
ParamList params_to_sign = ParamList() << Param("format_id", QString::number(format()))
@ -123,7 +131,7 @@ void QobuzStreamURLRequest::GetStreamURL() {
data_to_sign += param.first + param.second;
}
data_to_sign += QString::number(timestamp);
data_to_sign += app_secret();
data_to_sign += secret.toUtf8();
QByteArray const digest = QCryptographicHash::hash(data_to_sign.toUtf8(), QCryptographicHash::Md5);
QString signature = QString::fromLatin1(digest.toHex()).rightJustified(32, '0').toLower();