Skip to content
เข้าสู่ระบบ

Cryptography

Go มี crypto packages ที่ครบถ้วนสำหรับ encryption, hashing, และ signatures

package main
import (
"crypto/md5"
"crypto/sha256"
"crypto/sha512"
"fmt"
)
func main() {
data := []byte("Hello, World!")
// SHA-256 (recommended)
sha256Hash := sha256.Sum256(data)
fmt.Printf("SHA-256: %x\n", sha256Hash)
// SHA-512
sha512Hash := sha512.Sum512(data)
fmt.Printf("SHA-512: %x\n", sha512Hash[:32]) // แค่ 32 bytes แรก
// MD5 (NOT recommended for security)
md5Hash := md5.Sum(data)
fmt.Printf("MD5: %x\n", md5Hash)
}

เข้าสู่ระบบเพื่อดูเนื้อหาเต็ม

ยืนยันตัวตนด้วยบัญชี Google เพื่อปลดล็อกบทความทั้งหมด