เครื่องสร้างแฮช SHA-512
สร้างแฮช SHA-512 จากข้อความใดก็ได้
ข้อความอินพุต
แฮช SHA-512
แฮช SHA-512 จะแสดงที่นี่…
SHA-512 Hashing คืออะไร?
SHA-512 เป็นฟังก์ชันแฮชเข้ารหัสลับที่กำหนดไว้ใน NIST FIPS 180-4 ในฐานะสมาชิกที่ใหญ่ที่สุดของตระกูล SHA-2 รับอินพุตที่มีความยาวเท่าใดก็ได้และสร้าง message digest ขนาดคงที่ 512 บิต (64 ไบต์) ซึ่งแสดงเป็นสตริงตัวอักษรฐานสิบหก 128 ตัว SHA-512 ถูกนำไปใช้ในลายเซ็นดิจิทัล (Ed25519 พึ่งพา SHA-512 ภายใน), โครงสร้าง HMAC, การตรวจสอบความสมบูรณ์ของไฟล์ และโปรโตคอลการเข้ารหัสลับที่ต้องการระยะห่างด้านความปลอดภัยที่กว้าง
SHA-512 ประมวลผลบนบล็อก 1024 บิต (128 ไบต์) โดยใช้การคำนวณแบบเวิร์ด 64 บิตและ 80 รอบการบีบอัด ค่าแฮชเริ่มต้นทั้งแปดของมันได้จากส่วนทศนิยมของรากที่สองของจำนวนเฉพาะแปดตัวแรก และค่าคงที่ประจำรอบ 80 ค่ามาจากรากที่สามของจำนวนเฉพาะ 80 ตัวแรก เนื่องจากใช้การดำเนินการ 64 บิตโดยกำเนิด SHA-512 จึงมักเร็วกว่า SHA-256 บนโปรเซสเซอร์ 64 บิตสมัยใหม่ แม้จะสร้าง digest ที่ยาวกว่า
SHA-384, SHA-512/224 และ SHA-512/256 ล้วนเป็นตัวแปรที่ถูกตัดทอนของ SHA-512 ซึ่งมีโครงสร้างภายในเหมือนกันแต่ใช้ค่าแฮชเริ่มต้นที่แตกต่างกันและสร้างบิตน้อยกว่า เมื่อคุณต้องการความยาว digest สูงสุดที่ตระกูล SHA-2 มี หรือเมื่อโปรโตคอลกำหนดให้ใช้ SHA-512 โดยเฉพาะ (เช่น Ed25519 หรือบางรูปแบบการอนุมานคีย์ที่ใช้ HMAC) SHA-512 คือตัวเลือกที่ถูกต้อง มันให้ความทนทานต่อ collision 256 บิต ซึ่งเทียบเท่า SHA-3-512 และเหนือกว่าขอบ 128 บิตของ SHA-256 มาก
ทำไมต้องใช้เครื่องสร้าง SHA-512 ออนไลน์?
การสร้างแฮช SHA-512 มักต้องใช้คำสั่ง terminal หรือเขียนโค้ดสองสามบรรทัด เครื่องมือในเบราว์เซอร์นี้ให้คุณสร้าง SHA-512 digest ได้ทันทีโดยไม่ต้องติดตั้งซอฟต์แวร์ เปลี่ยนไปใช้ terminal หรือเขียนสคริปต์ชั่วคราว
กรณีการใช้งานเครื่องสร้างแฮช SHA-512
การเปรียบเทียบตัวแปรในตระกูล SHA-2
SHA-512 อยู่ในตระกูล SHA-2 ที่กำหนดใน FIPS 180-4 ตารางด้านล่างเปรียบเทียบตัวแปร SHA-2 ที่ใช้สถาปัตยกรรมภายใน 64 บิตของ SHA-512 ร่วมกัน พร้อมกับ SHA-256 เป็นข้อมูลอ้างอิง
| ตัวแปร | ขนาด Digest | ความยาว Hex | ขนาดไบต์ | เหมาะสำหรับ |
|---|---|---|---|---|
| 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 เทียบกับ SHA-256, SHA-384 และ SHA-3-512
การเลือกอัลกอริทึมแฮชที่ถูกต้องขึ้นอยู่กับข้อกำหนดด้านความปลอดภัย ข้อจำกัดด้านประสิทธิภาพ และข้อกำหนดของโปรโตคอล SHA-512 ให้ digest ที่กว้างที่สุดในตระกูล SHA-2 และมักเร็วกว่า SHA-256 บนฮาร์ดแวร์ 64 บิต การเปรียบเทียบนี้ครอบคลุมคุณสมบัติที่สำคัญที่สุดในการเลือกระหว่างอัลกอริทึมเหล่านี้
| คุณสมบัติ | 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 |
SHA-512 ทำงานภายในอย่างไร
SHA-512 ประมวลผลอินพุตผ่านโครงสร้าง Merkle–Damgård โดยใช้บล็อก 1024 บิต เริ่มต้นสถานะเวิร์ด 64 บิตแปดตัว (H0–H7) จากส่วนทศนิยมของรากที่สองของจำนวนเฉพาะแปดตัวแรก แต่ละบล็อกผ่าน 80 รอบของการผสมที่ใช้การดำเนินการระดับบิต (AND, XOR, NOT, right-rotate, right-shift) บนเวิร์ด 64 บิต ร่วมกับค่าคงที่ประจำรอบ 80 ค่าจากรากที่สามของจำนวนเฉพาะ 80 ตัวแรก
SHA-512: 309ecc489c12d6eb4cc40f50c902f2b4d0ed77ee511a7c7a9bcd3ca86d4cd86f
989dd35bc5ff499670da34255b45b0cfd830e81f605dcf7dc5542e93ae9cd76f
(512 bits = 64 bytes = 128 hex characters)
| ขั้นตอน | คำอธิบาย |
|---|---|
| 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. |
ขนาดเวิร์ด 64 บิตที่กว้างขึ้นเป็นตัวแยกความแตกต่างหลักจาก SHA-256 บน CPU 64 บิต แต่ละการดำเนินการประมวลผลบิตเป็นสองเท่าต่อรอบ ซึ่งเป็นเหตุผลที่ SHA-512 มักมีประสิทธิภาพเหนือกว่า SHA-256 ใน benchmark แม้จะรัน 80 รอบแทน 64 คุณสมบัติ avalanche ทำให้การพลิกบิตอินพุตเพียงบิตเดียวทำให้ประมาณ 50% ของบิตเอาต์พุต 512 บิตทั้งหมดเปลี่ยนแปลง
ตัวอย่างโค้ด SHA-512
SHA-512 รองรับโดยตรงในทุกภาษาและ runtime หลัก Web Crypto API ให้มันในเบราว์เซอร์โดยไม่ต้องใช้ไลบรารีใดๆ ตัวอย่างด้านล่างครอบคลุมรูปแบบทั่วไปรวมถึงการจัดการ Unicode และการแฮชไฟล์
// 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...