🛠️ToolsShed

Calculadora de hash de archivos

Calcula hashes MD5, SHA-1, SHA-256 y SHA-512 de cualquier archivo directamente en el navegador.

No file selected

Preguntas Frecuentes

Implementación de Código

import hashlib
from pathlib import Path

def hash_file(path: str, algorithm: str = "sha256") -> str:
    """Compute the hash of a file in chunks (memory-efficient)."""
    h = hashlib.new(algorithm)
    with open(path, "rb") as f:
        for chunk in iter(lambda: f.read(65536), b""):
            h.update(chunk)
    return h.hexdigest()

# Supported: md5, sha1, sha256, sha512, sha3_256, blake2b ...
file_path = "example.txt"

print("MD5:    ", hash_file(file_path, "md5"))
print("SHA-1:  ", hash_file(file_path, "sha1"))
print("SHA-256:", hash_file(file_path, "sha256"))
print("SHA-512:", hash_file(file_path, "sha512"))

# Hash a string directly
text = "Hello, World!"
sha256 = hashlib.sha256(text.encode()).hexdigest()
print("String SHA-256:", sha256)

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.