frostfs-sdk-go/object/id/test/generate.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
431 B
Go

package oidtest
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 {
var id oid.ID
id.SetSHA256(cs)
return id
}