mirror of
https://github.com/golang/go
synced 2024-11-26 07:47:57 -07:00
crypto/sha{256,512}: unname result parameters for consistency
Sum224 and Sum256 didn't look the same at: https://golang.org/pkg/crypto/sha256/ Now they match. Likewise with sha512's funcs. Per: https://github.com/golang/go/wiki/CodeReviewComments#named-result-parameters Change-Id: I6b88c8ef15141c78a6cddeb0960b3ad52db34244 Reviewed-on: https://go-review.googlesource.com/c/go/+/322329 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org> Trust: Katie Hockman <katie@golang.org> Reviewed-by: Katie Hockman <katie@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit is contained in:
parent
717894cf80
commit
57c115e1f6
@ -259,12 +259,12 @@ func Sum256(data []byte) [Size]byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sum224 returns the SHA224 checksum of the data.
|
// Sum224 returns the SHA224 checksum of the data.
|
||||||
func Sum224(data []byte) (sum224 [Size224]byte) {
|
func Sum224(data []byte) [Size224]byte {
|
||||||
var d digest
|
var d digest
|
||||||
d.is224 = true
|
d.is224 = true
|
||||||
d.Reset()
|
d.Reset()
|
||||||
d.Write(data)
|
d.Write(data)
|
||||||
sum := d.checkSum()
|
sum := d.checkSum()
|
||||||
copy(sum224[:], sum[:Size224])
|
ap := (*[Size224]byte)(sum[:])
|
||||||
return
|
return *ap
|
||||||
}
|
}
|
||||||
|
@ -337,31 +337,31 @@ func Sum512(data []byte) [Size]byte {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sum384 returns the SHA384 checksum of the data.
|
// Sum384 returns the SHA384 checksum of the data.
|
||||||
func Sum384(data []byte) (sum384 [Size384]byte) {
|
func Sum384(data []byte) [Size384]byte {
|
||||||
d := digest{function: crypto.SHA384}
|
d := digest{function: crypto.SHA384}
|
||||||
d.Reset()
|
d.Reset()
|
||||||
d.Write(data)
|
d.Write(data)
|
||||||
sum := d.checkSum()
|
sum := d.checkSum()
|
||||||
copy(sum384[:], sum[:Size384])
|
ap := (*[Size384]byte)(sum[:])
|
||||||
return
|
return *ap
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sum512_224 returns the Sum512/224 checksum of the data.
|
// Sum512_224 returns the Sum512/224 checksum of the data.
|
||||||
func Sum512_224(data []byte) (sum224 [Size224]byte) {
|
func Sum512_224(data []byte) [Size224]byte {
|
||||||
d := digest{function: crypto.SHA512_224}
|
d := digest{function: crypto.SHA512_224}
|
||||||
d.Reset()
|
d.Reset()
|
||||||
d.Write(data)
|
d.Write(data)
|
||||||
sum := d.checkSum()
|
sum := d.checkSum()
|
||||||
copy(sum224[:], sum[:Size224])
|
ap := (*[Size224]byte)(sum[:])
|
||||||
return
|
return *ap
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sum512_256 returns the Sum512/256 checksum of the data.
|
// Sum512_256 returns the Sum512/256 checksum of the data.
|
||||||
func Sum512_256(data []byte) (sum256 [Size256]byte) {
|
func Sum512_256(data []byte) [Size256]byte {
|
||||||
d := digest{function: crypto.SHA512_256}
|
d := digest{function: crypto.SHA512_256}
|
||||||
d.Reset()
|
d.Reset()
|
||||||
d.Write(data)
|
d.Write(data)
|
||||||
sum := d.checkSum()
|
sum := d.checkSum()
|
||||||
copy(sum256[:], sum[:Size256])
|
ap := (*[Size256]byte)(sum[:])
|
||||||
return
|
return *ap
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user