• python352+PyQT5 btcdice.com 验证程序


     0. 求打赏:

    Doge: DU5zf68E7x4YtMayUaX91z6dQDouS2u5ae
    LTC : LR4Qm8Cc2jKRdV4MZCpXtrAE8SZ2dXuj1o

    #!/usr/bin/python3
    from PyQt5.QtWidgets import *
    from PyQt5.QtGui import *
    from PyQt5.QtCore import *
    import hashlib
    import random
    import hmac
    import sys
    
    # Changelog:
    # Date : 2016-06-28 10:56:46 
    #       BugFixed : No function for verify the server seed hash, now fixed !
    
    groupCalculateData = []
    
    def calculateData(serverSeed, clientSeed, clientBetID, clientBetRange):
        groupCalculateData.clear()
        for betid in range(int(clientBetID), int(clientBetRange)):
            groupTemp = []
            client_seed_id = clientSeed + ":" + str(betid)
            hmac_512 = hmac.new(serverSeed.encode('utf-8'), client_seed_id.encode('utf-8'), hashlib.sha512).hexdigest()
            i = 0
            roll = -1
            while (roll == -1):
               if i == 25:
                  roll_default = int(hmac_512[125:128], 16)
                  roll = roll_defualt / 10000
               else:
                  roll_unit_start = 5 * i
                  roll_unit_end = 5 + 5 * i
                  roll_default = int(hmac_512[roll_unit_start:roll_unit_end], 16)
                  if roll_default < 1000000:
                     roll = roll_default / 10000
               i += 1
    
            groupTemp.append(str(betid))
            groupTemp.append(str(roll))
            groupCalculateData.append(groupTemp)
        # print(groupCalculateData)
    
    
    class Window(QWidget):
        def __init__(self):
            super(Window, self).__init__()
            
            self.verifyDataGroup = QGroupBox('')
            self.verifyDataGroup.setFixedWidth(350)
            
            self.verifyData = QTextEdit()
            # self.verifyData.setPlaceholderText('Paste the information here:')
            self.verifyData.setPlainText('点击账户-换手气,然后复制验证资料粘贴到此处,
    如果你觉得好用请打赏点
    LTC:LR4Qm8Cc2jKRdV4MZCpXtrAE8SZ2dXuj1o
    Doge:DU5zf68E7x4YtMayUaX91z6dQDouS2u5ae')
            # setFixedWidth / setFixedHeight
            self.verifyData.setFixedHeight(70)
            self.verifyData.setFocus()
            
            self.serverSeed = QLineEdit()
            self.serverSeed.setPlaceholderText('服务器种子')
            
            self.serverSeedHash = QLineEdit()
            self.serverSeedHash.setPlaceholderText('服务器种子Hash值')
            
            self.clientSeed = QLineEdit()
            self.clientSeed.setPlaceholderText('客户端种子:(换手气的时候可以自定义)')
            
            self.clientBetID = QLineEdit()
            self.clientBetID.setPlaceholderText('下注的ID')
            
            self.clientBetRange = QLineEdit()
            self.clientBetRange.setPlaceholderText('下注的范围')
            
            # Verify Button
            self.verifyButton = QPushButton('验证资料')
            self.verifyButton.clicked.connect(self.queryButtonClicked)
            
            # Calculate Button
            self.calculateButton = QPushButton('计算结果')
            self.calculateButton.clicked.connect(self.calculateButtonClicked)
            self.calculateButton.hide()        
            
            # Client Bet items
            self.clientBetLayout = QHBoxLayout()
            self.clientBetLayout.addStretch()
            self.clientBetLayout.addWidget(self.clientBetID)
            self.clientBetLayout.addWidget(self.clientBetRange)
            self.clientBetLayout.addWidget(self.verifyButton)
            self.clientBetLayout.addWidget(self.calculateButton)
            
            # QVBoxLayout() / QHBoxLayout() / QGridLayout() 
            self.verifyDataLayout = QGridLayout() 
            self.verifyDataLayout.addWidget(self.verifyData, 1, 0)
            self.verifyDataLayout.addWidget(self.serverSeed, 2, 0, 1, 1)
            self.verifyDataLayout.addWidget(self.serverSeedHash, 3, 0)
            self.verifyDataLayout.addWidget(self.clientSeed, 4, 0)
            self.verifyDataLayout.addLayout(self.clientBetLayout, 5, 0)
            self.verifyDataGroup.setLayout(self.verifyDataLayout)
            
            # Result Group
            self.verifyResultGroup = QGroupBox('')
            self.verifyResultView = QTableView()
            self.verifyResultViewModel = QStandardItemModel()
            self.verifyResultView.verticalHeader().hide()
            
            
            self.verifyResultLayout = QVBoxLayout()
            self.verifyResultLayout.addWidget(self.verifyResultView)
            self.verifyResultGroup.setLayout(self.verifyResultLayout)
            
            self.Layout = QGridLayout()
            self.Layout.addWidget(self.verifyDataGroup, 0, 0)
            self.Layout.addWidget(self.verifyResultGroup, 0, 1)
            
            self.setLayout(self.Layout)
            self.setWindowTitle('BTCDICE验证公平软件 @v20160628_v1.3 1626478661')
            self.resize(400, 200)
            
            # Disable zoom+ 
            # self.setWindowFlags(Qt.FramelessWindowHint|Qt.WindowSystemMenuHint)
            # Qt.WindowMinimizeButtonHint / 
            self.setWindowFlags(Qt.WindowCloseButtonHint)
            
            self.setFixedSize(520, 220)
            
        def queryButtonClicked(self):
            verifyDataValues = self.verifyData.toPlainText()
            verifyDataValuesGroup = verifyDataValues.split('" "')
            if len(verifyDataValuesGroup) == 4:
                serverSeed = verifyDataValuesGroup[0][1:]
                serverSeedHash = hashlib.sha256(serverSeed.encode('utf-8')).hexdigest()
                if serverSeedHash == verifyDataValuesGroup[1]:
                    QMessageBox.information(self, '提示', '种子验证成功!', QMessageBox.Yes)
                    self.serverSeed.setText(serverSeed)
                    self.serverSeedHash.setText(serverSeedHash)
                    self.clientSeed.setText(verifyDataValuesGroup[2])
                    self.clientBetID.setText(verifyDataValuesGroup[3].replace('"',''))
                    self.clientBetRange.setText(str(int(self.clientBetID.text()) + 2))
                    
                    self.calculateButton.show()
                else:
                    QMessageBox.warning(self, '错误', '验证失败!服务器种子hash值有误!', QMessageBox.Yes)
                    self.verifyData.clear()
                    self.verifyData.setFocus()
                    
                    self.serverSeed.clear()
                    self.serverSeedHash.clear()
                    self.clientSeed.clear()
                    self.clientBetID.clear()
                    self.clientBetRange.clear()
                    
                    self.calculateButton.hide()
            else:
                QMessageBox.warning(self, '错误', '验证失败!复制的信息格式有误!', QMessageBox.Yes)
                self.verifyData.clear()
                self.verifyData.setFocus()
                
        def calculateButtonClicked(self):
            if len(self.clientBetRange.text()) < 0:
                print("Error! BetRange should > 0")
            else:
                self.verifyResultViewModel.clear()
                self.verifyResultView.setModel(self.verifyResultViewModel)
                self.verifyResultViewModel.queryViewHeader = ['BetID', 'Result']
                self.verifyResultViewModel.setHorizontalHeaderLabels(self.verifyResultViewModel.queryViewHeader)
                self.verifyResultView.resizeColumnToContents(0)
                self.verifyResultView.resizeColumnToContents(1)
                self.verifyResultView.horizontalHeader().setStretchLastSection(True)
                calculateData(self.serverSeed.text(), self.clientSeed.text(), self.clientBetID.text(), self.clientBetRange.text())
                # print(groupCalculateData)
                
                for clientBetIDItem in range(len(groupCalculateData)):
                    # sort 
                    clientBetIDItemNew = len(groupCalculateData) - clientBetIDItem - 1
                    resultRow = []
                    resultRow.append(QStandardItem(groupCalculateData[clientBetIDItemNew][0]))
                    resultRow.append(QStandardItem(groupCalculateData[clientBetIDItemNew][1]))
                    self.verifyResultViewModel.appendRow(resultRow)
                    
    
    app = QApplication(sys.argv)
    win = Window()
    win.show()
    app.exec_()
  • 相关阅读:
    Java8 Lambda表达式详解手册及实例
    成功,侥幸,以小博大?永远离不开的墨菲定律
    Java8 Stream性能如何及评测工具推荐
    康威定律,作为架构师还不会灵活运用?
    Java8 Stream新特性详解及实战
    Java SPI机制实战详解及源码分析
    jQuery是什么
    庞氏骗局
    excel中VBA的使用
    wcf ServiceContract
  • 原文地址:https://www.cnblogs.com/topshooter/p/python352_pyqt5_BDverify.html
Copyright © 2020-2023  润新知