Generatore Hash SHA-512
Genera hash SHA-512 da qualsiasi testo
Testo di input
Hash SHA-512
L'hash SHA-512 apparirà qui…
Cos'è l'Hashing SHA-512?
SHA-512 è una funzione hash crittografica definita nel NIST FIPS 180-4 come membro più grande della famiglia SHA-2. Accetta un input di lunghezza arbitraria e produce un message digest fisso a 512 bit (64 byte), visualizzato come stringa esadecimale di 128 caratteri. SHA-512 è utilizzato nelle firme digitali (Ed25519 usa SHA-512 internamente), nelle costruzioni HMAC, nella verifica dell'integrità dei file e nei protocolli crittografici che beneficiano di un ampio margine di sicurezza.
SHA-512 opera su blocchi da 1024 bit (128 byte) usando aritmetica a 64 bit e 80 round di compressione. I suoi otto valori hash iniziali derivano dalle parti frazionarie delle radici quadrate dei primi otto numeri primi, e le 80 costanti di round provengono dalle radici cubiche dei primi 80 numeri primi. Poiché utilizza operazioni native a 64 bit, SHA-512 è spesso più veloce di SHA-256 sui moderni processori a 64 bit, nonostante produca un digest più lungo.
SHA-384, SHA-512/224 e SHA-512/256 sono varianti troncate di SHA-512 che condividono la stessa struttura interna ma usano diversi valori hash iniziali e producono meno bit. Quando hai bisogno della massima lunghezza di digest offerta dalla famiglia SHA-2, o quando un protocollo impone specificatamente SHA-512 (come Ed25519 o certi schemi HMAC di derivazione delle chiavi), SHA-512 è la scelta corretta. Offre 256 bit di resistenza alle collisioni, in linea con SHA-3-512 e ben oltre i 128 bit di SHA-256.
Perché Usare un Generatore SHA-512 Online?
Calcolare un hash SHA-512 richiede di solito un comando da terminale o qualche riga di codice. Questo strumento basato su browser ti permette di generare digest SHA-512 istantaneamente senza installare software, passare al terminale o scrivere script usa e getta.
Casi d'Uso del Generatore Hash SHA-512
Confronto delle Varianti della Famiglia SHA-2
SHA-512 appartiene alla famiglia SHA-2 definita in FIPS 180-4. La tabella seguente confronta le varianti SHA-2 che condividono l'architettura interna a 64 bit di SHA-512, insieme a SHA-256 come riferimento.
| Variante | Dimensione Digest | Lunghezza Hex | Dimensione Byte | Ideale Per |
|---|---|---|---|---|
| SHA-256 | 256 bits | 64 hex chars | 32 bytes | TLS certificates, blockchain, JWTs, SRI |
| SHA-384 | 384 bits | 96 hex chars | 48 bytes | TLS 1.3 CertificateVerify, CNSA/Suite B |
| SHA-512 | 512 bits | 128 hex chars | 64 bytes | Digital signatures, HMAC, Ed25519, file integrity |
| SHA-512/224 | 224 bits | 56 hex chars | 28 bytes | SHA-512 speed on 64-bit CPUs, 224-bit output |
| SHA-512/256 | 256 bits | 64 hex chars | 32 bytes | SHA-512 speed on 64-bit CPUs, 256-bit output |
SHA-512 vs SHA-256 vs SHA-384 vs SHA-3-512
La scelta dell'algoritmo hash dipende dai requisiti di sicurezza, dai vincoli di prestazioni e dalle specifiche del protocollo. SHA-512 offre il digest più ampio della famiglia SHA-2 ed è spesso più veloce di SHA-256 su hardware a 64 bit. Questo confronto copre le proprietà più rilevanti nella scelta tra questi algoritmi.
| Proprietà | SHA-512 | SHA-256 | SHA-384 | SHA-3-512 |
|---|---|---|---|---|
| Digest size | 512 bits (128 hex) | 256 bits (64 hex) | 384 bits (96 hex) | 512 bits (128 hex) |
| Block size | 1024 bits | 512 bits | 1024 bits | 1600 bits (sponge) |
| Word size | 64 bits | 32 bits | 64 bits | N/A (sponge) |
| Rounds | 80 | 64 | 80 | 24 |
| Collision resistance | 2^256 operations | 2^128 operations | 2^192 operations | 2^256 operations |
| Security status | Secure | Secure | Secure | Secure |
| Standard | FIPS 180-4 | FIPS 180-4 | FIPS 180-4 | FIPS 202 |
| Web Crypto API | Yes | Yes | Yes | No |
| 64-bit optimized | Yes | No (32-bit words) | Yes | Yes |
| Primary use today | Ed25519, HMAC, file checksums | TLS, blockchain, SRI | TLS 1.3, CNSA | Backup standard |
Come Funziona SHA-512 Internamente
SHA-512 elabora l'input attraverso una costruzione di Merkle–Damgård usando blocchi da 1024 bit. Inizializza otto parole di stato a 64 bit (H0–H7) dalle parti frazionarie delle radici quadrate dei primi otto numeri primi. Ogni blocco passa attraverso 80 round di mixing che usano operazioni bitwise (AND, XOR, NOT, rotazione destra, scorrimento a destra) su parole a 64 bit, combinate con 80 costanti di round derivate dalle radici cubiche dei primi 80 numeri primi.
SHA-512: 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f
989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
(512 bits = 64 bytes = 128 hex characters)
| Passo | Descrizione |
|---|---|
| Padding | Append a 1-bit, then zeros until the message length is 896 mod 1024. Append the original length as a 128-bit big-endian integer. |
| Block splitting | Divide the padded message into 1024-bit (128-byte) blocks. |
| Message schedule | Expand each 16-word (64-bit) block into 80 words using sigma functions with right-rotate and right-shift operations on 64-bit values. |
| Compression | Process 80 rounds per block using Ch, Maj, and two Sigma functions with 80 round constants derived from the cube roots of the first 80 primes. |
| Output | Concatenate the eight 64-bit state words (H0–H7) into a 512-bit (64-byte) digest, rendered as 128 hexadecimal characters. |
La dimensione delle parole a 64 bit è il differenziatore chiave rispetto a SHA-256. Sui processori a 64 bit, ogni operazione elabora il doppio dei bit per ciclo, motivo per cui SHA-512 supera spesso SHA-256 nei benchmark nonostante esegua 80 round invece di 64. L'effetto valanga garantisce che invertire un singolo bit nell'input modifichi circa il 50% di tutti i 512 bit di output.
Esempi di Codice SHA-512
SHA-512 è supportato nativamente in tutti i principali linguaggi e runtime. La Web Crypto API lo fornisce nei browser senza alcuna libreria. Gli esempi seguenti coprono i pattern più comuni, inclusa la gestione Unicode e l'hashing di file.
// Works in all modern browsers and Node.js 18+
async function sha512(text) {
const data = new TextEncoder().encode(text)
const hashBuffer = await crypto.subtle.digest('SHA-512', data)
const hashArray = Array.from(new Uint8Array(hashBuffer))
return hashArray.map(b => b.toString(16).padStart(2, '0')).join('')
}
await sha512('hello world')
// → "309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f"
// Node.js (built-in crypto module)
const crypto = require('crypto')
crypto.createHash('sha512').update('hello world').digest('hex')
// → "309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f"import hashlib
# Basic SHA-512 hash
result = hashlib.sha512(b'hello world').hexdigest()
print(result)
# → "309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee..."
# Hash a string with Unicode (encode to bytes first)
text = 'café ☕'
hashlib.sha512(text.encode('utf-8')).hexdigest()
# → 128-character hex string
# Hash a large file in chunks (memory-efficient)
with open('release.tar.gz', 'rb') as f:
sha = hashlib.sha512()
for chunk in iter(lambda: f.read(8192), b''):
sha.update(chunk)
print(sha.hexdigest())package main
import (
"crypto/sha512"
"fmt"
)
func main() {
data := []byte("hello world")
hash := sha512.Sum512(data)
fmt.Printf("%x\n", hash)
// → 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f...
}# Using sha512sum (Linux) or shasum (macOS) echo -n "hello world" | sha512sum # → 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee... - # macOS echo -n "hello world" | shasum -a 512 # → 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee... - # Verify a file checksum echo "309ecc48... myfile.bin" | sha512sum -c # → myfile.bin: OK # Using openssl (cross-platform) echo -n "hello world" | openssl dgst -sha512 # → SHA2-512(stdin)= 309ecc489c12d6eb4cc40f50c902f2b4...