国产精品爱啪在线线免费观看_97视频精品_欧美精品一区二区在线播放_国产欧美久久一区二区三区

 找回密碼
 立即注冊

QQ登錄

只需一步,快速開始

搜索
查看: 7011|回復: 0

[開發交流] python封裝持續更新已完成讀取配置和校驗MD5

[復制鏈接]
1#
發表于 2022-5-21 19:09:16 | 只看該作者 |倒序瀏覽 |閱讀模式

馬上注冊,結交更多好友,享用更多功能,讓你輕松玩轉社區

您需要 登錄 才可以下載或查看,沒有賬號?立即注冊

×
在做一個pyqt程序,找了半天網絡驗證感覺這個挺好用,寫了下模塊校驗。get_md5()#獲取當前exe文件袋md5和云端對比返回結果,True為通過,False為md5不匹配soft_conf()#讀取當前軟件就配置,True返回版本,公告,下載地址,False返回空
[Python] 純文本查看 復制代碼
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import time
import traceback
import hashlib
import requests
import json
import os

class Ver():
    def __init__(self):
        self.url = 'https://bbs.52bangqi.com/plugin.php?id=xinxiu_network:login'
        self.key =  ''   #傳輸密鑰key:
        self.file ='ver.exe'    #打包后的exe絕對路徑

    def soft_conf(self):
        url = self.url+'&key={0}&action=login_config'.format(self.key)
        head={
            "Content-Type":"application/x-www-form-urlencoded"
        }
        try:
            res = requests.get(url,headers=head,)
            s = self.paser(res.text)
            #print(s)
            if int(s['code']) == 200:
                version = s['data']['version']
                notice = s['data']['Notice']
                updateurl = s['data']['updateurl']
                return version,notice,updateurl
        except:
            print(traceback.format_exc())
        return  []

    def paser(self,txt):
        return json.loads(txt)

    def get_md5(self):
        '''
        客戶端和服務端md5檢驗
        :return:
        '''
        url = self.url+'&key={0}&action=login_md5&rmd5={1}'.format(self.key,self.check_md5(self.file))
        print(self.check_md5(self.file))
        head={
            "Content-Type":"application/x-www-form-urlencoded"
        }
        try:
            res = requests.get(url,headers=head,)
            s = self.paser(res.text)
            #print(s)
            if int(s['code']) == 200:
                md5 = s['data']['md5']
                return True
        except:
            print(traceback.format_exc())
        return  False

    def check_md5(self,file):
        #獲取打包后的exe文件md5
        md = hashlib.md5()
        try:
            with open(file=file, mode='rb') as csna:
                block = csna.read(1024)
                while block:
                    md.update(block)
                    block = csna.read(1024)
            return md.hexdigest()
            # if md.hexdigest() == self.get_md5():
            #     print('驗證成功,軟件為正版')
            #     return True
        except:
            print(traceback.format_exc())
        print('驗證失敗')
        return  False
    def get_path(self):

        #文件絕對路徑
        return os.path.dirname(os.path.abspath(__file__))
if  __name__ =='__main__':
    #while True:
    s = Ver()
    #s.soft_conf()
    if s.get_md5():
        print("正版")
    else:
        print("請勿使用盜版程序")
    time.sleep(100)

帖子永久地址: 

新秀網絡驗證系統 - 論壇版權1、本主題所有言論和圖片純屬會員個人意見,與本論壇立場無關
2、本站所有主題由該帖子作者發表,該帖子作者與新秀網絡驗證系統享有帖子相關版權
3、其他單位或個人使用、轉載或引用本文時必須同時征得該帖子作者和新秀網絡驗證系統的同意
4、帖子作者須承擔一切因本文發表而直接或間接導致的民事或刑事法律責任
5、本帖部分內容轉載自其它媒體,但并不代表本站贊同其觀點和對其真實性負責
6、如本帖侵犯到任何版權問題,請立即告知本站,本站將及時予與刪除并致以最深的歉意
7、新秀網絡驗證系統管理員和版主有權不事先通知發貼者而刪除本文

您需要登錄后才可以回帖 登錄 | 立即注冊

本版積分規則

QQ|Archiver|手機版|新秀網絡驗證系統API[軟著登字第13061951號] ( 豫ICP備2021033257號-1 )

GMT+8, 2025-7-1 13:19 , Processed in 0.194707 second(s), 42 queries , Redis On.

Powered by Discuz! X3.5 Licensed

© 2001-2025 Discuz! Team.

快速回復 返回頂部 返回列表