mirror of
https://github.com/status-im/react-native-randombytes.git
synced 2026-08-30 10:31:08 +00:00
52 lines
1.2 KiB
C++
52 lines
1.2 KiB
C++
/**
|
|
* Copyright (C) 2016, Canonical Ltd.
|
|
* All rights reserved.
|
|
*
|
|
* This source code is licensed under the BSD-style license found in the
|
|
* LICENSE file in the root directory of this source tree. An additional grant
|
|
* of patent rights can be found in the PATENTS file in the same directory.
|
|
*
|
|
* Author: Justin McPherson <justin.mcpherson@canonical.com>
|
|
*
|
|
*/
|
|
|
|
#include <memory>
|
|
|
|
#include "bridge.h"
|
|
#include "rnrandombytes.h"
|
|
#include <QCryptographicHash>
|
|
#include <QDateTime>
|
|
#include <QMap>
|
|
#include <QNetworkDiskCache>
|
|
#include <QNetworkReply>
|
|
#include <QNetworkRequest>
|
|
#include <QQuickImageProvider>
|
|
|
|
class RNRandomBytesPrivate {
|
|
|
|
public:
|
|
RNRandomBytesPrivate() {
|
|
qsrand(QDateTime::currentDateTime().currentMSecsSinceEpoch());
|
|
while (seed.size() < 4096) {
|
|
seed.append(QChar(qrand()));
|
|
}
|
|
}
|
|
QString seed;
|
|
};
|
|
|
|
RNRandomBytes::RNRandomBytes(QObject* parent) : QObject(parent), d_ptr(new RNRandomBytesPrivate) {}
|
|
|
|
RNRandomBytes::~RNRandomBytes() {}
|
|
|
|
QString RNRandomBytes::moduleName() {
|
|
return "RNRandomBytes";
|
|
}
|
|
|
|
QList<ModuleMethod*> RNRandomBytes::methodsToExport() {
|
|
return QList<ModuleMethod*>{};
|
|
}
|
|
|
|
QVariantMap RNRandomBytes::constantsToExport() {
|
|
return QVariantMap{{"seed", d_ptr->seed}};
|
|
}
|