Skip to content

Instantly share code, notes, and snippets.

@touhonoob
Created May 10, 2019 07:09
Show Gist options
  • Save touhonoob/755e137ae67758f5c247c8432be1d821 to your computer and use it in GitHub Desktop.
Save touhonoob/755e137ae67758f5c247c8432be1d821 to your computer and use it in GitHub Desktop.

Revisions

  1. touhonoob created this gist May 10, 2019.
    20 changes: 20 additions & 0 deletions test.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    package main

    import (
    "crypto/sha256"
    "encoding/hex"
    "fmt"
    )

    func main() {
    right := "3187c721dc9913aef26a6cf1677a29a0c1c24229730911e68091eadf8839873"
    data := make([]byte, 64)
    right_bytes, _ := hex.DecodeString(right)
    copy(data[32:], right_bytes)

    hashed_with_empty_bytes := sha256.Sum256(data)
    fmt.Printf("with empty bytes: %s\n", hex.EncodeToString(hashed_with_empty_bytes[:]))

    hashed_without_empty_bytes := sha256.Sum256(right_bytes)
    fmt.Printf("without empty bytes: %s\n", hex.EncodeToString(hashed_without_empty_bytes[:]))
    }