特定id私钥生成脚本

runwu2204 Lv6

所需库 web3

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import eth_account
import secrets

def check_address_suffix(address, suffix):
return address[-4:].lower() == suffix.lower()

found = False
while not found:
# 使用安全的方式生成32字节的私钥
private_key_bytes = secrets.token_bytes(32)
private_key_int = int.from_bytes(private_key_bytes, 'big')
private_key_hex = hex(private_key_int)[2:].zfill(64)

# 创建账户对象并获取地址
account = eth_account.Account.privateKeyToAccount(private_key_bytes)
address = account.address.lower()

# 检查地址后四位是否为0x2024
if check_address_suffix(address, "2024"):
print(f"找到匹配地址: {address},对应的私钥是: {private_key_hex}")
found = True
  • 标题: 特定id私钥生成脚本
  • 作者: runwu2204
  • 创建于 : 2024-02-21 16:30:48
  • 更新于 : 2024-02-21 16:32:19
  • 链接: https://runwu2204.github.io/2024/02/21/智能合约/特定id私钥生成脚本/
  • 版权声明: 本文章采用 CC BY-NC-SA 4.0 进行许可。
评论
目录
特定id私钥生成脚本