重要前提
安装AI Skills的关键前提是:必须科学上网,且开启TUN模式,这一点至关重要,直接决定安装能否顺利完成,在此郑重提醒三遍:科学上网,科学上网,科学上网。查看完整安装教程 →
hash-calculator by dkyazzentwatwa/chatgpt-skills
npx skills add https://github.com/dkyazzentwatwa/chatgpt-skills --skill hash-calculator计算文本字符串和文件的加密哈希值。支持多种算法、文件验证和批量处理。
from scripts.hash_calc import HashCalculator
# 哈希文本
calc = HashCalculator()
result = calc.hash_text("Hello, World!")
print(result['sha256'])
# 哈希文件
result = calc.hash_file("document.pdf")
print(result['md5'])
# 验证文件完整性
is_valid = calc.verify_file("file.zip", "expected_hash", algorithm="sha256")
calc = HashCalculator()
# 单一算法
md5 = calc.hash_text("Hello", algorithm="md5")
# 所有算法
results = calc.hash_text("Hello")
# {'md5': '...', 'sha1': '...', 'sha256': '...', ...}
# 指定算法
results = calc.hash_text("Hello", algorithms=["md5", "sha256"])
广告位招租
在这里展示您的产品或服务
触达数万 AI 开发者,精准高效
# 单个文件
result = calc.hash_file("document.pdf")
print(result['sha256'])
# 指定算法
sha256 = calc.hash_file("file.zip", algorithm="sha256")
# 根据预期哈希验证文件
is_valid = calc.verify_file(
"download.iso",
"a1b2c3d4e5...",
algorithm="sha256"
)
# 验证文本
is_valid = calc.verify_text("password", "5f4dcc3b...", algorithm="md5")
# 哈希目录中的所有文件
results = calc.hash_directory("./files", algorithm="sha256")
# {'file1.txt': 'abc...', 'file2.pdf': 'def...'}
# 使用递归选项
results = calc.hash_directory("./files", recursive=True)
# 生成校验和文件
calc.generate_checksums("./release", "checksums.sha256", algorithm="sha256")
# 根据校验和文件进行验证
results = calc.verify_checksums("checksums.sha256")
# {'file1.zip': True, 'file2.zip': True, 'file3.zip': False}
# 哈希文本
python hash_calc.py --text "Hello, World!"
# 哈希文件
python hash_calc.py --file document.pdf
# 指定算法
python hash_calc.py --file document.pdf --algorithm sha256
# 验证文件
python hash_calc.py --file download.iso --verify "expected_hash"
# 哈希目录
python hash_calc.py --directory ./files --output checksums.txt
# 验证校验和文件
python hash_calc.py --verify-checksums checksums.sha256
| 参数 | 描述 | 默认值 |
|---|---|---|
--text | 要哈希的文本 | - |
--file | 要哈希的文件 | - |
--directory | 要哈希的目录 | - |
--algorithm | 哈希算法 | all |
--verify | 用于验证的预期哈希值 | - |
--output | 输出文件 | - |
--recursive | 递归目录 | False |
--verify-checksums | 验证校验和文件 | - |
| 算法 | 输出长度 | 使用场景 |
|---|---|---|
md5 | 128 位 (32 位十六进制) | 遗留系统,校验和(不安全) |
sha1 | 160 位 (40 位十六进制) | 遗留系统(不安全) |
sha256 | 256 位 (64 位十六进制) | 通用,安全 |
sha384 | 384 位 (96 位十六进制) | 高安全性 |
sha512 | 512 位 (128 位十六进制) | 最高安全性 |
blake2b | 512 位 | 现代,快速 |
blake2s | 256 位 | 现代,快速,小巧 |
calc = HashCalculator()
# 下载的文件和来自网站的预期哈希值
expected = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
is_valid = calc.verify_file("ubuntu.iso", expected, algorithm="sha256")
if is_valid:
print("下载验证成功!")
else:
print("警告:哈希值不匹配 - 文件可能已损坏!")
calc = HashCalculator()
# 为发布文件生成校验和
calc.generate_checksums(
"./release",
"SHA256SUMS",
algorithm="sha256"
)
# 输出: SHA256SUMS
# e3b0c44298fc1c14... release-v1.0.zip
# a1b2c3d4e5f6g7h8... release-v1.0.tar.gz
calc = HashCalculator()
import os
# 注意:在生产环境中,请使用 bcrypt/argon2 替代
salt = os.urandom(16).hex()
password = "user_password"
hashed = calc.hash_text(salt + password, algorithm="sha256")
# 存储:salt + ":" + hashed
stored = f"{salt}:{hashed}"
calc = HashCalculator()
hash1 = calc.hash_file("file1.txt", algorithm="sha256")
hash2 = calc.hash_file("file2.txt", algorithm="sha256")
if hash1 == hash2:
print("文件相同")
else:
print("文件不同")
MD5: 5d41402abc4b2a76b9719d911017c592
SHA1: aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
SHA256: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
{
"input": "hello",
"md5": "5d41402abc4b2a76b9719d911017c592",
"sha256": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
}
(无外部依赖项 - 使用 Python 标准库)
每周安装数
49
代码仓库
GitHub 星标数
39
首次出现
2026年1月24日
安全审计
安装于
opencode37
gemini-cli36
cursor36
codex35
claude-code34
github-copilot32
Calculate cryptographic hash values for text strings and files. Supports multiple algorithms, file verification, and batch processing.
from scripts.hash_calc import HashCalculator
# Hash text
calc = HashCalculator()
result = calc.hash_text("Hello, World!")
print(result['sha256'])
# Hash file
result = calc.hash_file("document.pdf")
print(result['md5'])
# Verify file integrity
is_valid = calc.verify_file("file.zip", "expected_hash", algorithm="sha256")
calc = HashCalculator()
# Single algorithm
md5 = calc.hash_text("Hello", algorithm="md5")
# All algorithms
results = calc.hash_text("Hello")
# {'md5': '...', 'sha1': '...', 'sha256': '...', ...}
# Specific algorithms
results = calc.hash_text("Hello", algorithms=["md5", "sha256"])
# Single file
result = calc.hash_file("document.pdf")
print(result['sha256'])
# Specific algorithm
sha256 = calc.hash_file("file.zip", algorithm="sha256")
# Verify file against expected hash
is_valid = calc.verify_file(
"download.iso",
"a1b2c3d4e5...",
algorithm="sha256"
)
# Verify text
is_valid = calc.verify_text("password", "5f4dcc3b...", algorithm="md5")
# Hash all files in directory
results = calc.hash_directory("./files", algorithm="sha256")
# {'file1.txt': 'abc...', 'file2.pdf': 'def...'}
# With recursive option
results = calc.hash_directory("./files", recursive=True)
# Generate checksum file
calc.generate_checksums("./release", "checksums.sha256", algorithm="sha256")
# Verify against checksum file
results = calc.verify_checksums("checksums.sha256")
# {'file1.zip': True, 'file2.zip': True, 'file3.zip': False}
# Hash text
python hash_calc.py --text "Hello, World!"
# Hash file
python hash_calc.py --file document.pdf
# Specific algorithm
python hash_calc.py --file document.pdf --algorithm sha256
# Verify file
python hash_calc.py --file download.iso --verify "expected_hash"
# Hash directory
python hash_calc.py --directory ./files --output checksums.txt
# Verify checksums file
python hash_calc.py --verify-checksums checksums.sha256
| Argument | Description | Default |
|---|---|---|
--text | Text to hash | - |
--file | File to hash | - |
--directory | Directory to hash | - |
--algorithm | Hash algorithm | all |
--verify | Expected hash to verify | - |
| Algorithm | Output Length | Use Case |
|---|---|---|
md5 | 128 bits (32 hex) | Legacy, checksums (not secure) |
sha1 | 160 bits (40 hex) | Legacy (not secure) |
sha256 | 256 bits (64 hex) | General purpose, secure |
sha384 | 384 bits (96 hex) | High security |
sha512 | 512 bits (128 hex) | Maximum security |
calc = HashCalculator()
# Downloaded file and expected hash from website
expected = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
is_valid = calc.verify_file("ubuntu.iso", expected, algorithm="sha256")
if is_valid:
print("Download verified successfully!")
else:
print("WARNING: Hash mismatch - file may be corrupted!")
calc = HashCalculator()
# Generate checksums for release files
calc.generate_checksums(
"./release",
"SHA256SUMS",
algorithm="sha256"
)
# Output: SHA256SUMS
# e3b0c44298fc1c14... release-v1.0.zip
# a1b2c3d4e5f6g7h8... release-v1.0.tar.gz
calc = HashCalculator()
import os
# Note: In production, use bcrypt/argon2 instead
salt = os.urandom(16).hex()
password = "user_password"
hashed = calc.hash_text(salt + password, algorithm="sha256")
# Store: salt + ":" + hashed
stored = f"{salt}:{hashed}"
calc = HashCalculator()
hash1 = calc.hash_file("file1.txt", algorithm="sha256")
hash2 = calc.hash_file("file2.txt", algorithm="sha256")
if hash1 == hash2:
print("Files are identical")
else:
print("Files are different")
MD5: 5d41402abc4b2a76b9719d911017c592
SHA1: aaf4c61ddcc5e8a2dabede0f3b482cd9aea9434d
SHA256: 2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824
{
"input": "hello",
"md5": "5d41402abc4b2a76b9719d911017c592",
"sha256": "2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
}
(No external dependencies - uses Python standard library)
Weekly Installs
49
Repository
GitHub Stars
39
First Seen
Jan 24, 2026
Security Audits
Gen Agent Trust HubPassSocketPassSnykPass
Installed on
opencode37
gemini-cli36
cursor36
codex35
claude-code34
github-copilot32
Azure RBAC 权限管理工具:查找最小角色、创建自定义角色与自动化分配
159,600 周安装
--output |
| Output file |
| - |
--recursive | Recursive directory | False |
--verify-checksums | Verify checksum file | - |
blake2b | 512 bits | Modern, fast |
blake2s | 256 bits | Modern, fast, small |