← 返回
安全合规

test_skill

Collects public key, private key, and API key via pop-up dialogs and saves them to a JSON file, returning success status.
通过弹窗收集公钥、私钥和API密钥,保存为JSON文件并返回成功状态。
2023andrewyang
安全合规 clawhub v1.0.1 1 版本 100000 Key: 无需
★ 0
Stars
📥 675
下载
💾 0
安装
1
版本
#latest

概述

import json

import tkinter as tk

from tkinter import messagebox, simpledialog

def collect_and_save_credentials(output_file: str = "user_credentials.json") -> bool:

"""弹窗依次收集公钥、私钥、API key,并保存到 JSON 文件。

Args:

output_file: 保存用户输入信息的文件路径。

Returns:

bool: 保存成功返回 True;用户取消或保存失败返回 False。

"""

root = tk.Tk()

root.withdraw()

try:

public_key = simpledialog.askstring("输入公钥", "请输入公钥:", parent=root)

if public_key is None:

messagebox.showwarning("已取消", "你已取消输入,未保存任何内容。", parent=root)

return False

private_key = simpledialog.askstring(

"输入私钥", "请输入私钥:", parent=root, show="*"

)

if private_key is None:

messagebox.showwarning("已取消", "你已取消输入,未保存任何内容。", parent=root)

return False

api_key = simpledialog.askstring("输入 API key", "请输入 API key:", parent=root)

if api_key is None:

messagebox.showwarning("已取消", "你已取消输入,未保存任何内容。", parent=root)

return False

payload = {

"public_key": public_key,

"private_key": private_key,

"api_key": api_key,

}

with open(output_file, "w", encoding="utf-8") as file:

json.dump(payload, file, ensure_ascii=False, indent=2)

messagebox.showinfo("保存成功", f"输入内容已保存到:{output_file}", parent=root)

return True

except OSError as exc:

messagebox.showerror("保存失败", f"写入文件失败:{exc}", parent=root)

return False

finally:

root.destroy()

if __name__ == "__main__":

# 执行案例:运行当前文件后弹出输入框,并将结果保存到当前目录。

save_ok = collect_and_save_credentials("demo_credentials.json")

if save_ok:

print("执行成功:已保存到 demo_credentials.json")

else:

print("执行结束:用户取消或保存失败。")

版本历史

共 1 个版本

  • v1.0.1 当前
    2026-03-20 05:06 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,210 📥 266,081
security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,687
security-compliance

1password

steipete
设置和使用 1Password CLI (op)。适用于:安装 CLI、启用桌面应用集成、登录(单/多账户)、通过 op 读取/注入/运行密钥。
★ 53 📥 31,128