-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal/loghash: move (soon-to-be-) shared code to its own package
Change-Id: Id8c7d5752449b0bb82a2b21157cb067f6a8be18b Reviewed-on: https://go-review.googlesource.com/10871 Reviewed-by: Brad Fitzpatrick <[email protected]>
- Loading branch information
Showing
2 changed files
with
23 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright 2015 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
// Package loghash provides the shared information for computing | ||
// a log hash (as in https://build.golang.org/log/HASH). | ||
package loghash | ||
|
||
import ( | ||
"crypto/sha1" | ||
"fmt" | ||
"io" | ||
) | ||
|
||
// New returns a new hash for the given log text. | ||
func New(text string) (hash string) { | ||
h := sha1.New() | ||
io.WriteString(h, text) | ||
return fmt.Sprintf("%x", h.Sum(nil)) | ||
} |