frostfs-sdk-go/container/id/test/id.go
Evgenii Stratonikov 372468c320 [#41] container: move id from neofs-api-go
Change `Marshal` signature to `Marshal() ([]byte, error)`.
Dependency update in SDK itself should be done after moving client
as `pool` package has some dependent function signatures.

Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
2021-11-01 17:52:27 +03:00

26 lines
472 B
Go

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