ISO C++ forbids variable length array
This commit is contained in:
parent
f32a999b4e
commit
036980eb44
1 changed files with 5 additions and 2 deletions
|
@ -18,12 +18,15 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt
|
|||
|
||||
QByteArray passwordBuffer = (salt + password).toUtf8();
|
||||
int hashLen = gcry_md_get_algo_dlen(algo);
|
||||
char hash[hashLen], tmp[hashLen];
|
||||
char *hash = new char[hashLen], *tmp = new char[hashLen];
|
||||
gcry_md_hash_buffer(algo, hash, passwordBuffer.data(), passwordBuffer.size());
|
||||
for (int i = 1; i < rounds; ++i) {
|
||||
memcpy(tmp, hash, hashLen);
|
||||
gcry_md_hash_buffer(algo, hash, tmp, hashLen);
|
||||
}
|
||||
return salt + QString(QByteArray(hash, hashLen).toBase64());
|
||||
QString hashedPass = salt + QString(QByteArray(hash, hashLen).toBase64());
|
||||
delete[] tmp;
|
||||
delete[] hash;
|
||||
return hashedPass;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue