opencontainers / go-digest

Common digest package used across the container ecosystem
https://www.opencontainers.org/
Other
184 stars 60 forks source link

Clarify inconsistency with standard sha256sum utility. #47

Closed siscia closed 4 years ago

siscia commented 4 years ago

Hi all,

maybe is me missing something but if I run:

package main

import (
    _ "crypto/sha256"
    "fmt"
    "github.com/opencontainers/go-digest"
)

func main() {
    fmt.Println(digest.FromBytes([]byte("A")))
    // "sha256:559aead08264d5795d3909718cdd05abd49572e84fe55590eef31a88a08fdffd"
}

I get as input: sha256:559aead08264d5795d3909718cdd05abd49572e84fe55590eef31a88a08fdffd

However if I run:

$ echo A | sha256sum 
06f961b802bc46ee168555f066d28f4f0e9afdf3f88174c1ee6f9de004fc30a0  -

Is this inconsistency wanted?

siscia commented 4 years ago

Solved!

$ echo -n A | sha256sum 
559aead08264d5795d3909718cdd05abd49572e84fe55590eef31a88a08fdffd  -

echo append a \n to the end of the message!

vbatts commented 4 years ago

Oh good. You caught it before I could reply. 🤓

On Wed, Sep 25, 2019, 05:58 Simone Mosciatti notifications@github.com wrote:

Closed #47 https://github.com/opencontainers/go-digest/issues/47.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/opencontainers/go-digest/issues/47?email_source=notifications&email_token=AAAQL2JC3XUMBFPRTES7VCTQLMY23A5CNFSM4I2KO4V2YY3PNVWWK3TUL52HS4DFWZEXG43VMVCXMZLOORHG65DJMZUWGYLUNFXW5KTDN5WW2ZLOORPWSZGOT2OIQNQ#event-2661058614, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAQL2JARQDSHCOGNM4EZQLQLMY23ANCNFSM4I2KO4VQ .