/** * 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 * */ #include #include "bridge.h" #include "rnsecurerandom.h" #include #include #include #include namespace { struct RegisterQMLMetaType { RegisterQMLMetaType() { qRegisterMetaType(); } } registerMetaType; } // namespace class RNSecureRandomPrivate { public: Bridge* bridge = nullptr; }; RNSecureRandom::RNSecureRandom(QObject* parent) : QObject(parent), d_ptr(new RNSecureRandomPrivate) {} RNSecureRandom::~RNSecureRandom() {} void RNSecureRandom::generateSecureRandomAsBase64(int size, const ModuleInterface::ListArgumentBlock &resolve, const ModuleInterface::ListArgumentBlock &reject) { Q_D(RNSecureRandom); qDebug()<<"invoked RNSecureRandom::generateSecureRandomAsBase64"; QByteArray randomString; qsrand(QDateTime::currentDateTime().currentMSecsSinceEpoch()); while (randomString.size() < size) { randomString.push_back(qrand()); } QString result = randomString.toBase64(); qDebug()<<"RNSecureRandom::generateSecureRandomAsBase64 result: "<bridge, QVariantList{QVariant{result}}); } QString RNSecureRandom::moduleName() { return "RNSecureRandom"; } QList RNSecureRandom::methodsToExport() { return QList{}; } QVariantMap RNSecureRandom::constantsToExport() { return QVariantMap{}; } void RNSecureRandom::setBridge(Bridge* bridge) { Q_D(RNSecureRandom); d->bridge = bridge; }