吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 69|回复: 0
收起左侧

[Python 原创] 批量生成Web3助记词钱包

[复制链接]
Pablo 发表于 2025-3-16 19:05
本帖最后由 Pablo 于 2025-3-16 19:07 编辑

笔者常用三方钱包或工具站生成助记词钱包,但研究 “善恶” 久了,难免疑心很重,总觉得三方钱包有后门,工具站可能挂马,
生成的钱包心里用的不踏实,于是弄了个在本地离线生成助记词钱包的小工具,如果你也有这方面的诉求,下方自取:

[Python] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import random
from mnemonic import Mnemonic
import tkinter as tk
from tkinter import ttk, messagebox, scrolledtext
 
# 生成助记词的函数
def generate_mnemonic(count, words_num=12):
    mnemonics = []
    mnemo = Mnemonic("english")
     
    # 更新 strength 字典以支持 12, 15, 18, 21 和 24 个单词
    strength = {
        12: 128# 12词对应128位
        15: 160# 15词对应160位
        18: 192# 18词对应192位
        21: 224# 21词对应224位
        24: 256   # 24词对应256位
    }
     
    for _ in range(count):
        # 生成助记词
        mnemonic = mnemo.generate(strength=strength.get(words_num, 128))  # 默认12词
        mnemonics.append(mnemonic)
     
    return mnemonics
 
# GUI 生成助记词
def generate_mnemonics_gui():
    try:
        # 获取用户输入的数量和助记词长度
        count = int(entry_count.get())
        words_num = int(combobox_words_num.get())
         
        # 检查助记词长度是否有效
        if words_num not in [12, 15, 18, 21, 24]:
            messagebox.showerror("错误", "助记词长度必须是 12, 15, 18, 21 或 24")
            return
         
        # 生成助记词
        mnemonics = generate_mnemonic(count, words_num)
         
        # 清空文本框并显示生成的助记词
        text_output.delete(1.0, tk.END)
        for mnemonic in mnemonics:
            text_output.insert(tk.END, mnemonic + "\n\n")
    except ValueError:
        messagebox.showerror("错误", "请输入有效的数字")
 
# 创建主窗口
root = tk.Tk()
root.title("助记词生成器")
 
# 设置窗口大小
root.geometry("500x400")
 
# 设置窗口的最小大小
root.minsize(500, 400)
 
# 创建输入框和标签
label_count = tk.Label(root, text="生成数量:", width=10, anchor="w")
label_count.grid(row=0, column=0, padx=5, pady=5, sticky="w")
entry_count = tk.Entry(root, width=20)
entry_count.grid(row=0, column=1, padx=5, pady=5, sticky="ew")
 
label_words_num = tk.Label(root, text="助记词长度:", width=10, anchor="w")
label_words_num.grid(row=1, column=0, padx=5, pady=5, sticky="w")
combobox_words_num = ttk.Combobox(root, values=[12, 15, 18, 21, 24], state="readonly", width=18)
combobox_words_num.current(0# 默认选择第一个选项
combobox_words_num.grid(row=1, column=1, padx=5, pady=5, sticky="ew")
 
# 创建生成按钮,占两行高度
button_generate = tk.Button(root, text="生成助记词", command=generate_mnemonics_gui, width=15, height=4)
button_generate.grid(row=0, column=2, rowspan=2, padx=5, pady=5, sticky="ns")
 
# 创建文本框用于显示助记词
text_output = scrolledtext.ScrolledText(root, wrap=tk.WORD)
text_output.grid(row=3, column=0, columnspan=3, padx=5, pady=5, sticky="nsew")
 
# 设置网格布局的权重,使文本框可以随窗口大小调整
root.grid_rowconfigure(3, weight=1)
root.grid_columnconfigure(0, weight=1)
root.grid_columnconfigure(1, weight=1)
root.grid_columnconfigure(2, weight=1# 按钮列也需要扩展
 
# 运行主循环
root.mainloop()




image.png
image.png

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-3-20 04:53

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表