Skip to content

Commit

Permalink
*: clarify we only deal with hex-encoded digests
Browse files Browse the repository at this point in the history
Also fixes a typo and adds one clarifying link in the README.

Fixes #31

Signed-off-by: Jonathan Boulle <[email protected]>
  • Loading branch information
jonboulle committed Mar 9, 2017
1 parent aa2ec05 commit b74b840
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Please see the [godoc](https://godoc.org/github.com/opencontainers/go-digest) fo

# What is a digest?

A digest is just a hash.
A digest is just a [hash](https://en.wikipedia.org/wiki/Hash_function).

The most common use case for a digest is to create a content
identifier for use in [Content Addressable Storage](https://en.wikipedia.org/wiki/Content-addressable_storage)
Expand Down Expand Up @@ -60,18 +60,21 @@ out when using this package.
```go
import (
_ "crypto/sha256"
_ "crypto/sha512"
_ "crypto/sha512"
)
```
This may seem inconvenient but it allows you replace the hash
implementations with others, such as https://github.com/stevvooe/resumable.

2. Even though `digest.Digest` may be assemable as a string, _always_
2. Even though `digest.Digest` may be assemblable as a string, _always_
verify your input with `digest.Parse` or use `Digest.Validate`
when accepting untrusted input. While there are measures to
avoid common problems, this will ensure you have valid digests
in the rest of your application.

3. While alternative encodings of hash values (digests) are possible (for
example, base64), this package deals exclusively with hex-encoded digests.

# Stability

The Go API, at this stage, is considered stable, unless otherwise noted.
Expand Down
2 changes: 2 additions & 0 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
// In this case, the string "sha256" is the algorithm and the hex bytes are
// the "digest".
//
// This package exclusively uses hex encoding for all digests.
//
// Because the Digest type is simply a string, once a valid Digest is
// obtained, comparisons are cheap, quick and simple to express with the
// standard equality operator.
Expand Down

0 comments on commit b74b840

Please sign in to comment.