Skip to content
This repository has been archived by the owner on Oct 26, 2021. It is now read-only.

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronFeng753 committed Oct 20, 2020
1 parent 226e133 commit 64a00ff
Show file tree
Hide file tree
Showing 10 changed files with 789 additions and 0 deletions.
Binary file added Donate.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 11 additions & 0 deletions Donate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# ❤ Donate 捐赠 ❤ (PayPal, 支付宝&微信)
```
Please donate to support developers, so we can bring further update for this software, thank you! (。・∀・)ノ゙
```
```
请捐赠以支持开发者, 您的支持是我们更新软件的动力, 谢谢您! (。・∀・)ノ゙
```
---
# [PayPal](https://www.paypal.me/aaronfeng753)
---
![DonateJPG](/Donate.jpg)
27 changes: 27 additions & 0 deletions SRC/StringToSeed.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-

# Copyright (C) 2020 Aaron Feng

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.

# 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 Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# My Github homepage: https://github.com/AaronFeng753

import random
import sys

argv_list = sys.argv
seed_str = argv_list[1]
random.seed(seed_str)
print (random.randint(1, 4294967290))
2 changes: 2 additions & 0 deletions SRC/SyncToy_355287a5-305c-4513-93e7-fbaa0aec8f84.dat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
��R5\0E����
52 changes: 52 additions & 0 deletions SRC/WebcamTRNG.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# Copyright (C) 2020 Aaron Feng

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.

# 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 Affero General Public License for more details.

# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

# My Github homepage: https://github.com/AaronFeng753

QT += core gui

QT += multimedia multimediawidgets

QT += concurrent

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

CONFIG += c++11

# The following define makes your compiler emit warnings if you use
# any Qt feature that has been marked deprecated (the exact warnings
# depend on your compiler). Please consult the documentation of the
# deprecated API in order to know how to port your code away from it.
DEFINES += QT_DEPRECATED_WARNINGS

# You can also make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
# You can also select to disable deprecated APIs only up to a certain version of Qt.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0

SOURCES += \
main.cpp \
mainwindow.cpp

HEADERS += \
mainwindow.h

FORMS += \
mainwindow.ui

# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
325 changes: 325 additions & 0 deletions SRC/WebcamTRNG.pro.user

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions SRC/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
Copyright (C) 2020 Aaron Feng
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
My Github homepage: https://github.com/AaronFeng753
*/


#include "mainwindow.h"

#include <QApplication>

int main(int argc, char *argv[])
{
QCoreApplication::setAttribute(Qt::AA_EnableHighDpiScaling);//高分辨率屏幕支持
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
118 changes: 118 additions & 0 deletions SRC/mainwindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
Copyright (C) 2020 Aaron Feng
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
My Github homepage: https://github.com/AaronFeng753
*/


#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::MainWindow)
{
ui->setupUi(this);
//===
this->setWindowTitle("WebcamTRNG "+VERSION+" by Aaron Feng");
//===
connect(imageCapture, SIGNAL(imageSaved(int, const QString)), this, SLOT(ImageIsReady()));
}

MainWindow::~MainWindow()
{
delete ui;
}

//==========================================================
/*
============= 安全的阻塞延时 =====================
*/
void MainWindow::Delay_sec_sleep(int time)
{
QThread::sleep(time);
}

void MainWindow::Delay_msec_sleep(int time)
{
QThread::msleep(time);
}
//==========================================================

void MainWindow::on_pushButton_Generate_clicked()
{
connect(camera, SIGNAL(statusChanged(QCamera::Status)), this, SLOT(CheckCam()));
NotifyStatus=true;
camera->start();
//拍照保存照片
QDateTime time = QDateTime::currentDateTime();
QString Current_Time = time.toString("ss_zzz");
QString pic_path = Application_Current_Path+"/1.jpg";
imageCapture->capture(pic_path);
}

void MainWindow::ImageIsReady()
{
QString pic_path = Application_Current_Path+"/1.jpg";
QFile file(pic_path);
QByteArray byteArray;
if(file.open(QIODevice::ReadOnly))
{
byteArray = file.readAll();
}
QCryptographicHash hash(QCryptographicHash::Md5);
hash.addData(byteArray); // 添加数据到加密哈希值
QByteArray result = hash.result(); // 返回最终的哈希值
QString strMD5 = result.toHex();
QString program = Application_Current_Path+"/StringToSeed.exe";
QProcess getSeed;
getSeed.start("\""+program+"\" "+strMD5);
while(!getSeed.waitForStarted(100)) {}
while(!getSeed.waitForFinished(100)) {}
quint32 Seed=getSeed.readAllStandardOutput().toULong();
QRandomGenerator QRandomGenerator_self(Seed);
ui->lineEdit_ResNum_int->setText(QString::number(QRandomGenerator_self.bounded(ui->spinBox_MinNum_int->value(),ui->spinBox_MaxNum_int->value())));
QFile::remove(pic_path);
}

void MainWindow::CheckCam()
{
if(camera->status()==QCamera::UnavailableStatus && NotifyStatus==true)
{
QMessageBox *MSG = new QMessageBox();
MSG->setWindowTitle(tr("Error"));
MSG->setText("No webcam available.");
MSG->setIcon(QMessageBox::Warning);
MSG->setModal(false);
MSG->show();
NotifyStatus=false;
}
}

void MainWindow::on_pushButton_CheckUpdate_clicked()
{
QDesktopServices::openUrl(QUrl("https://github.com/AaronFeng753/WebcamTRNG/releases"));
}

void MainWindow::on_pushButton_Donate_clicked()
{
QDesktopServices::openUrl(QUrl("https://github.com/AaronFeng753/WebcamTRNG/blob/master/Donate.md"));
}

void MainWindow::on_pushButton_OfficalSite_clicked()
{
QDesktopServices::openUrl(QUrl("https://github.com/AaronFeng753/WebcamTRNG"));
}
87 changes: 87 additions & 0 deletions SRC/mainwindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
Copyright (C) 2020 Aaron Feng
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
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 Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
My Github homepage: https://github.com/AaronFeng753
*/

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <qcoreapplication.h>

#include <QCamera>
#include <QCameraViewfinder>
#include <QCameraImageCapture>

#include <QThread>
#include <QRandomGenerator>
#include <QFile>
#include <QCryptographicHash>
#include <QDateTime>
#include <QProcess>
#include <QMessageBox>

#include <QDesktopServices>
#include <QUrl>

QT_BEGIN_NAMESPACE
namespace Ui
{
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
Q_OBJECT

public:
MainWindow(QWidget *parent = nullptr);
~MainWindow();

QString VERSION = "v0.01";//软件版本号

QString Application_Current_Path = qApp->applicationDirPath();//当前路径

QCamera *camera = new QCamera(); // 摄像头对象
QCameraImageCapture *imageCapture = new QCameraImageCapture(camera); // 用于截取摄像头图像

bool NotifyStatus=true;

void Delay_sec_sleep(int time);

void Delay_msec_sleep(int time);

private slots:

void on_pushButton_Generate_clicked();

void on_pushButton_CheckUpdate_clicked();

void on_pushButton_Donate_clicked();

void on_pushButton_OfficalSite_clicked();

public slots:

void ImageIsReady();
void CheckCam();

private:
Ui::MainWindow *ui;
};
#endif // MAINWINDOW_H
Loading

0 comments on commit 64a00ff

Please sign in to comment.