Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Donald Haase
Cockatrice
Commits
036980eb
Commit
036980eb
authored
Jul 24, 2014
by
Fabio Bas
Browse files
ISO C++ forbids variable length array
parent
f32a999b
Changes
1
Hide whitespace changes
Inline
Side-by-side
servatrice/src/passwordhasher.cpp
View file @
036980eb
...
@@ -18,12 +18,15 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt
...
@@ -18,12 +18,15 @@ QString PasswordHasher::computeHash(const QString &password, const QString &salt
QByteArray
passwordBuffer
=
(
salt
+
password
).
toUtf8
();
QByteArray
passwordBuffer
=
(
salt
+
password
).
toUtf8
();
int
hashLen
=
gcry_md_get_algo_dlen
(
algo
);
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
());
gcry_md_hash_buffer
(
algo
,
hash
,
passwordBuffer
.
data
(),
passwordBuffer
.
size
());
for
(
int
i
=
1
;
i
<
rounds
;
++
i
)
{
for
(
int
i
=
1
;
i
<
rounds
;
++
i
)
{
memcpy
(
tmp
,
hash
,
hashLen
);
memcpy
(
tmp
,
hash
,
hashLen
);
gcry_md_hash_buffer
(
algo
,
hash
,
tmp
,
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
;
}
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment