frostfs-sdk-go/object/id/test/generate.go
Pavel Karpy e8eac3997c [#128] object: Move ID and Address in subpkg
This is done to prevent import cycles when `object` package needs any other
that requires `object.ID` or `object.Address`.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
2022-02-01 17:03:12 +03:00

26 lines
434 B
Go

package test
import (
"crypto/sha256"
"math/rand"
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
)
// ID returns random object.ID.
func ID() *oid.ID {
checksum := [sha256.Size]byte{}
rand.Read(checksum[:])
return idWithChecksum(checksum)
}
// idWithChecksum returns object.ID initialized
// with specified checksum.
func idWithChecksum(cs [sha256.Size]byte) *oid.ID {
id := oid.NewID()
id.SetSHA256(cs)
return id
}