зеркало из https://github.com/golang/build.git
21 строка
509 B
Go
21 строка
509 B
Go
// 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))
|
|
}
|