当前位置: 首页 > news >正文

【用Python根据用户名和手机号码生成Hash值并创建.cs .h和xlsx文件】

用Python根据用户名和手机号码生成Hash值并创建C Sharp .cs、嵌入式.h和xlsx表格文件


用Python根据用户名和手机号码生成Hash值并创建C Sharp .cs、嵌入式.h和xlsx表格文件,主要是为每个用户创建一个pubkey,并输出C Sharp C#和嵌入式 Keil的工程文件 pubkey.cs和pubkey.h文件。并把用户名和手机号码记录在excel表格中。

def writeinpara():global usernameglobal emailusername=input('请输入用户名:')email=input('请输入手机号码:')print("username="+username+"; Email="+email)
#生成md5 hashh
def md5_hash(data: str) -> str:m = hashlib.md5()m.update(data.encode('utf-8'))return m.hexdigest()

下面建立目录

def createDir(dirpath,username,email):global urlurl=dirpath+username+"_"+emailif(os.path.exists(dirpath+username+"_"+email)):shutil.rmtree(url)  #删除目录,包括目录下的所有文件os.mkdir(url,0o777)

下面写入CS文件

    print("writeCSfile =",filepath)if os.path.isfile(filepath):os.remove(filepath)#encoding='utf-8-sig'    #with open(filepath, "w", encoding="utf-8") as file:with open(filepath, "w", encoding='utf-8-sig') as file:file.write(csFileStrBegin+hexdigest+csFileStrEnd)file.close()#if os.path.isfile(filepath):#    print("CS file exist,open it!")#    with open(filepath, "w", encoding="utf-8") as file:#    file.write(csFileStrBegin+hexdigest+csFileStrEnd)#worksheet = workbook.active#else:#文件不存在,创建新的Exce1文件#    print("CS file created!")

写入.h文件

def writeHfile(filepath,username,email,hexdigest):lengthint=len(hexdigest)lengthstr=str(lengthint)print("writeHfile =",filepath)if os.path.isfile(filepath):os.remove(filepath)with open(filepath, "w", encoding="utf-8") as file:file.write("#define USER_PUBKEY_LEN   "+lengthstr+"\r")file.write("#define USER_PUBKEY   \""+hexdigest+"\"\r")file.close()

写入excel文件

def writepubkey(workbook,username,email,hexdigest):#sheet = workbook.get_sheet_by_name('sheet1')sheet = workbook.active#last_row = sheet.max_row + 1# 获取当前日期和时间now = datetime.datetime.now()# 格式化日期和时间datevalue = now.strftime("%Y-%m-%d")timevalue = now.strftime("%H:%M:%S")insertData = [datevalue,timevalue, username,email,hexdigest]sheet.append(insertData)#sheet.cell(last_row+1,  column=1,value=datevalue)#sheet.cell(last_row+1,  column=2,value=timevalue)#sheet.cell(last_row+1,  column=3,value=username)#sheet.cell(last_row+1,  column=4,value=email)#sheet.cell(last_row+1,  column=5,value=hexdigest)# 保存Excel文件workbook.save(filepath)workbook.close()

视频:B站 柔贝特三哥

一个脚本工具调用Python生产pubkey和嵌入式.h文件和.cs的c#文件,调用keil和visual studio编译arm和c#的工程,执行文件拷贝功能

http://www.lryc.cn/news/250341.html

相关文章:

  • <Linux>(极简关键、省时省力)《Linux操作系统原理分析之存储管理(2)》(15)
  • jdk8、jdk9中,接口的新特性
  • 第一题-字符串拼接【第六届传智杯程序设计挑战赛解题分析详解复盘】(C/C++实现)
  • 简谈oracle数据库的归档模式
  • FLASK博客系列9——你想成为我的新用户吗?
  • 用通俗的方法讲解:大模型微调训练详细说明(附理论+实践代码)
  • 现代化工安全保障迎来巡查无人机新时代
  • 关于web前端通过js获取后端mysql数据库数据的一个方法
  • 如何下载IEEE出版社的Journal/Conference/Magazine的LaTeX/Word模板
  • 京东数据运营-京东数据开放平台-鲸参谋10月粮油调味市场品牌店铺销售数据分析
  • ThermalLabel SDK for .NET 13.0.23.1113 Crack
  • [Java学习日记]网络编程
  • spring boot mybatis TypeHandler 看源码如何初始化及调用
  • 数据结构基础(带头节点的双向循环链表)
  • STM32CubeMx+MATLAB Simulink点灯程序
  • 【深度学习】gan网络原理生成对抗网络
  • springboot参数汇总
  • 【算法刷题】Day9
  • LangChain的函数,工具和代理(三):LangChain中轻松实现OpenAI函数调用
  • WiFi概念介绍
  • 如何优雅的进行业务分层
  • C++的std命名空间
  • unity学习笔记
  • 使用SpringBoot和ZXing实现二维码生成与解析
  • C++模板—函数模板、类模板
  • Monkey
  • SQL中left join、right join、inner join等的区别
  • 算法学习—排序
  • 在Pycharm中创建项目新环境,安装Pytorch
  • linux里source、sh、bash、./有什么区别