frostfs-sdk-go/container/id/test/id.go
Pavel Karpy f7172adf18 [#170] oid, cid: Refactor and document package functionality
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-04-13 17:32:25 +03:00

26 lines
428 B
Go

package cidtest
import (
"crypto/sha256"
"math/rand"
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
)
// ID returns random cid.ID.
func ID() cid.ID {
checksum := [sha256.Size]byte{}
rand.Read(checksum[:])
return IDWithChecksum(checksum)
}
// IDWithChecksum returns cid.ID initialized
// with specified checksum.
func IDWithChecksum(cs [sha256.Size]byte) cid.ID {
var id cid.ID
id.SetSHA256(cs)
return id
}