Otavio Mariano commited on
Upload verificar_hash.py with huggingface_hub
Browse files- verificar_hash.py +100 -0
verificar_hash.py
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""
|
| 3 |
+
Script de Verificação do Hash do Sistema VICK AI
|
| 4 |
+
Este script verifica se o certificado no HuggingFace é autêntico
|
| 5 |
+
"""
|
| 6 |
+
|
| 7 |
+
import hashlib
|
| 8 |
+
import json
|
| 9 |
+
import sys
|
| 10 |
+
|
| 11 |
+
# Hash oficial registrado
|
| 12 |
+
HASH_OFICIAL = "196660c17a32fdc82764f738bcb3b8cc6f93bc7df942977ca9a8fc0a5e6c3e73"
|
| 13 |
+
|
| 14 |
+
def calcular_hash(arquivo_json):
|
| 15 |
+
"""Calcula hash SHA-256 do arquivo JSON"""
|
| 16 |
+
try:
|
| 17 |
+
with open(arquivo_json, 'r', encoding='utf-8') as f:
|
| 18 |
+
conteudo = f.read()
|
| 19 |
+
|
| 20 |
+
hash_calculado = hashlib.sha256(conteudo.encode('utf-8')).hexdigest()
|
| 21 |
+
return hash_calculado
|
| 22 |
+
except Exception as e:
|
| 23 |
+
print(f"❌ Erro ao calcular hash: {e}")
|
| 24 |
+
return None
|
| 25 |
+
|
| 26 |
+
def verificar_componentes(arquivo_json):
|
| 27 |
+
"""Verifica componentes do fingerprint"""
|
| 28 |
+
try:
|
| 29 |
+
with open(arquivo_json, 'r', encoding='utf-8') as f:
|
| 30 |
+
data = json.load(f)
|
| 31 |
+
|
| 32 |
+
print("\n📊 Informações do Certificado:")
|
| 33 |
+
print(f" Sistema: {data.get('system')}")
|
| 34 |
+
print(f" Versão: {data.get('version')}")
|
| 35 |
+
print(f" Criador: {data.get('creator')}")
|
| 36 |
+
print(f" Timestamp: {data.get('timestamp')}")
|
| 37 |
+
|
| 38 |
+
total_components = data.get('metadata', {}).get('total_components', 0)
|
| 39 |
+
print(f"\n📁 Total de Componentes: {total_components}")
|
| 40 |
+
|
| 41 |
+
print("\n🧬 Fingerprint do Modelo LLM:")
|
| 42 |
+
llm_fp = data.get('component_details', {}).get('00_llm_fingerprint', {})
|
| 43 |
+
for key, value in llm_fp.items():
|
| 44 |
+
print(f" • {key}: {value}")
|
| 45 |
+
|
| 46 |
+
return True
|
| 47 |
+
except Exception as e:
|
| 48 |
+
print(f"❌ Erro ao ler componentes: {e}")
|
| 49 |
+
return False
|
| 50 |
+
|
| 51 |
+
def main():
|
| 52 |
+
print("="*80)
|
| 53 |
+
print("🔐 VERIFICADOR DE HASH - SISTEMA VICK AI")
|
| 54 |
+
print("="*80)
|
| 55 |
+
|
| 56 |
+
arquivo = "vick_fingerprint.json"
|
| 57 |
+
|
| 58 |
+
print(f"\n📄 Arquivo: {arquivo}")
|
| 59 |
+
print(f"🎯 Hash Oficial: {HASH_OFICIAL}")
|
| 60 |
+
|
| 61 |
+
# Calcula hash do arquivo
|
| 62 |
+
print(f"\n⏳ Calculando hash do arquivo...")
|
| 63 |
+
hash_calculado = calcular_hash(arquivo)
|
| 64 |
+
|
| 65 |
+
if not hash_calculado:
|
| 66 |
+
print("\n❌ FALHA NA VERIFICAÇÃO")
|
| 67 |
+
sys.exit(1)
|
| 68 |
+
|
| 69 |
+
print(f"✓ Hash Calculado: {hash_calculado}")
|
| 70 |
+
|
| 71 |
+
# Compara hashes
|
| 72 |
+
print(f"\n🔍 Comparando hashes...")
|
| 73 |
+
|
| 74 |
+
if hash_calculado == HASH_OFICIAL:
|
| 75 |
+
print("\n" + "="*80)
|
| 76 |
+
print("✅ CERTIFICADO AUTÊNTICO!")
|
| 77 |
+
print("="*80)
|
| 78 |
+
print("\nO hash calculado corresponde ao hash oficial registrado.")
|
| 79 |
+
print("Este certificado é genuíno e não foi alterado desde o registro.")
|
| 80 |
+
|
| 81 |
+
# Mostra componentes
|
| 82 |
+
verificar_componentes(arquivo)
|
| 83 |
+
|
| 84 |
+
print("\n" + "="*80)
|
| 85 |
+
print("✓ Verificação concluída com sucesso")
|
| 86 |
+
print("="*80)
|
| 87 |
+
sys.exit(0)
|
| 88 |
+
else:
|
| 89 |
+
print("\n" + "="*80)
|
| 90 |
+
print("❌ CERTIFICADO INVÁLIDO!")
|
| 91 |
+
print("="*80)
|
| 92 |
+
print("\n⚠️ ATENÇÃO: O hash não corresponde ao hash oficial.")
|
| 93 |
+
print("Este arquivo pode ter sido modificado ou corrompido.")
|
| 94 |
+
print("\nHash esperado:", HASH_OFICIAL)
|
| 95 |
+
print("Hash calculado:", hash_calculado)
|
| 96 |
+
print("\n" + "="*80)
|
| 97 |
+
sys.exit(1)
|
| 98 |
+
|
| 99 |
+
if __name__ == "__main__":
|
| 100 |
+
main()
|