QSslCertificatePrivate: make use of QByteArray::toHex(separator)

Qt 5.9 introduced a QByteArray::toHex() overload that
inserts a separator char after each byte. The function
colonSeparatedHex() could not be replaced completely,
as it skips leading zeros also.

Change-Id: Ic1d5d4771a0a5171f0e7e9813b83eb4c1f59f085
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
bb10
Andre Hartmann 2017-04-21 07:59:54 +02:00 committed by Liang Qi
parent bdb1a5b283
commit 8a8788f4df
1 changed files with 6 additions and 11 deletions

View File

@ -272,17 +272,12 @@ QList<QSslCertificate> QSslCertificatePrivate::certificatesFromDer(const QByteAr
static QByteArray colonSeparatedHex(const QByteArray &value)
{
QByteArray hexString;
hexString.reserve(value.size() * 3);
for (int a = 0; a < value.size(); ++a) {
const quint8 b = value.at(a);
if (b || !hexString.isEmpty()) { // skip leading zeros
hexString += QByteArray::number(b, 16).rightJustified(2, '0');
hexString += ':';
}
}
hexString.chop(1);
return hexString;
const int size = value.size();
int i = 0;
while (i < size && !value.at(i)) // skip leading zeros
++i;
return value.mid(i).toHex(':');
}
bool QSslCertificatePrivate::parse(const QByteArray &data)