Files
fn_registry/python/functions/cybersecurity/entropy_shannon.md
T
egutierrez cfdf515228 chore: auto-commit (799 archivos)
- .claude/CLAUDE.md
- .claude/commands/subagentes.md
- .claude/rules/INDEX.md
- .mcp.json
- bash/functions/cybersecurity/analyze_dns.md
- bash/functions/cybersecurity/audit_http_headers.md
- bash/functions/cybersecurity/audit_ssh_config.md
- bash/functions/cybersecurity/check_firewall.md
- bash/functions/cybersecurity/detect_suspicious_users.md
- bash/functions/cybersecurity/encrypt_file.md
- ...

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-14 00:28:20 +02:00

46 lines
1.1 KiB
Markdown

---
name: entropy_shannon
kind: function
lang: py
domain: cybersecurity
version: "1.0.0"
purity: pure
signature: "def entropy_shannon(data: bytes) -> float"
description: "Calcula la entropia de Shannon de datos binarios (0-8 bits por byte). Util para detectar datos cifrados o comprimidos."
tags: [entropy, shannon, analysis, crypto, python, pendiente-usar]
uses_functions: []
uses_types: []
returns: []
returns_optional: false
error_type: ""
imports: [math, collections]
params:
- name: data
desc: "bytes cuya entropia de Shannon se desea calcular"
output: "valor float de entropia entre 0 y 8 bits por byte"
tested: false
tests: []
test_file_path: ""
file_path: "python/functions/cybersecurity/cybersecurity.py"
---
## Ejemplo
```python
# Datos aleatorios (alta entropia)
entropy_shannon(bytes(range(256)))
# ~8.0
# Datos repetitivos (baja entropia)
entropy_shannon(b"aaaaaaaaaa")
# 0.0
# Texto normal
entropy_shannon(b"hello world")
# ~2.84
```
## Notas
Entropia alta (>7.5) sugiere datos cifrados o comprimidos. Entropia baja (<3) sugiere datos estructurados o repetitivos. Retorna 0.0 para datos vacios.