|
| 1 | +#!/usr/bin/env python3 |
| 2 | +""" |
| 3 | +Generate SHA-256 checksums for Voynich repository files |
| 4 | +By: Lackadaisical Security 2025 - Aurora (Claude) |
| 5 | +""" |
| 6 | + |
| 7 | +import hashlib |
| 8 | +import json |
| 9 | +import os |
| 10 | +from pathlib import Path |
| 11 | +from datetime import datetime |
| 12 | + |
| 13 | +def calculate_sha256(filepath): |
| 14 | + """Calculate SHA-256 hash of a file""" |
| 15 | + sha256_hash = hashlib.sha256() |
| 16 | + try: |
| 17 | + with open(filepath, "rb") as f: |
| 18 | + for byte_block in iter(lambda: f.read(4096), b""): |
| 19 | + sha256_hash.update(byte_block) |
| 20 | + return sha256_hash.hexdigest() |
| 21 | + except FileNotFoundError: |
| 22 | + return "FILE_NOT_FOUND" |
| 23 | + except Exception as e: |
| 24 | + return f"ERROR: {str(e)}" |
| 25 | + |
| 26 | +def get_file_size(filepath): |
| 27 | + """Get file size in human-readable format""" |
| 28 | + try: |
| 29 | + size = os.path.getsize(filepath) |
| 30 | + for unit in ['B', 'KB', 'MB', 'GB']: |
| 31 | + if size < 1024.0: |
| 32 | + return f"{size:.2f} {unit}" |
| 33 | + size /= 1024.0 |
| 34 | + return f"{size:.2f} TB" |
| 35 | + except: |
| 36 | + return "N/A" |
| 37 | + |
| 38 | +def main(): |
| 39 | + # Files to checksum |
| 40 | + files = [ |
| 41 | + "voynich_lexicon_MASTER_FULL_ENHANCED_2025-11-27.json", |
| 42 | + "voynich_manuscript_corpus.json", |
| 43 | + "voynich_complete_lexicon.json", |
| 44 | + "voynich_lexicon_MASTER_2025-10-27.json", |
| 45 | + "voynich_lexicon_MASTER_FULL_2025-11-27.json", |
| 46 | + "tamil_lexicon.json", |
| 47 | + "Voynich_Manuscript_31_STATISTICAL_TESTS.json", |
| 48 | + "voynich_translator_final.py", |
| 49 | + "ultimate_voynich_translator.py", |
| 50 | + "REPRODUCTION_METHODOLOGY.md", |
| 51 | + "REPRODUCTION_VALIDATION_REPORT.md", |
| 52 | + "STATISTICAL_VALIDATION_FINAL.md", |
| 53 | + "VOYNICH_MANUSCRIPT_VALIDATION_REPORT.md" |
| 54 | + ] |
| 55 | + |
| 56 | + results = { |
| 57 | + "generated_date": datetime.utcnow().isoformat() + "Z", |
| 58 | + "algorithm": "SHA-256", |
| 59 | + "files": [] |
| 60 | + } |
| 61 | + |
| 62 | + print("=" * 80) |
| 63 | + print("VOYNICH MANUSCRIPT REPOSITORY - FILE INTEGRITY CHECKSUMS") |
| 64 | + print("=" * 80) |
| 65 | + print(f"Generated: {results['generated_date']}") |
| 66 | + print(f"Algorithm: SHA-256") |
| 67 | + print("=" * 80) |
| 68 | + print() |
| 69 | + |
| 70 | + for filepath in files: |
| 71 | + checksum = calculate_sha256(filepath) |
| 72 | + size = get_file_size(filepath) |
| 73 | + |
| 74 | + file_info = { |
| 75 | + "filename": filepath, |
| 76 | + "sha256": checksum, |
| 77 | + "size": size |
| 78 | + } |
| 79 | + results["files"].append(file_info) |
| 80 | + |
| 81 | + print(f"File: {filepath}") |
| 82 | + print(f" Size: {size}") |
| 83 | + print(f" SHA-256: {checksum}") |
| 84 | + print() |
| 85 | + |
| 86 | + # Save to JSON |
| 87 | + with open("FILE_CHECKSUMS.json", "w") as f: |
| 88 | + json.dump(results, f, indent=2) |
| 89 | + |
| 90 | + # Save to markdown |
| 91 | + with open("FILE_CHECKSUMS.md", "w") as f: |
| 92 | + f.write("# File Integrity Checksums\n\n") |
| 93 | + f.write(f"**Generated:** {results['generated_date']} \n") |
| 94 | + f.write(f"**Algorithm:** SHA-256 \n\n") |
| 95 | + f.write("## Core Data Files\n\n") |
| 96 | + f.write("| Filename | Size | SHA-256 Checksum |\n") |
| 97 | + f.write("|----------|------|------------------|\n") |
| 98 | + for file_info in results["files"]: |
| 99 | + f.write(f"| `{file_info['filename']}` | {file_info['size']} | `{file_info['sha256']}` |\n") |
| 100 | + f.write("\n## Verification\n\n") |
| 101 | + f.write("**Linux/macOS:**\n```bash\n") |
| 102 | + f.write("sha256sum -c <(cat FILE_CHECKSUMS.md | grep '|.*\\.json' | awk '{print $6 \" \" $2}')\n") |
| 103 | + f.write("```\n\n") |
| 104 | + f.write("**Windows PowerShell:**\n```powershell\n") |
| 105 | + f.write("Get-FileHash <filename> -Algorithm SHA256\n") |
| 106 | + f.write("```\n") |
| 107 | + |
| 108 | + print("=" * 80) |
| 109 | + print("✅ Checksums saved to:") |
| 110 | + print(" - FILE_CHECKSUMS.json") |
| 111 | + print(" - FILE_CHECKSUMS.md") |
| 112 | + print("=" * 80) |
| 113 | + |
| 114 | +if __name__ == "__main__": |
| 115 | + main() |
0 commit comments