mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2025-12-16 17:04:20 -05:00
Add crypto classes and tests. Link to libgcrypt.
This commit is contained in:
parent
f5dd24fdbe
commit
6a2034fa24
15 changed files with 684 additions and 5 deletions
39
src/crypto/Random.cpp
Normal file
39
src/crypto/Random.cpp
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* Copyright (C) 2010 Felix Geyer <debfx@fobos.de>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 2 or (at your option)
|
||||
* version 3 of the License.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "Random.h"
|
||||
|
||||
#include <gcrypt.h>
|
||||
|
||||
void Random::randomize(QByteArray& ba)
|
||||
{
|
||||
gcry_randomize(ba.data(), ba.size(), GCRY_STRONG_RANDOM);
|
||||
}
|
||||
|
||||
QByteArray Random::randomArray(int len)
|
||||
{
|
||||
QByteArray ba;
|
||||
ba.resize(len);
|
||||
|
||||
randomize(ba);
|
||||
|
||||
return ba;
|
||||
}
|
||||
|
||||
Random::Random()
|
||||
{
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue