package intulid import ( "encoding/binary" "fmt" "github.com/oklog/ulid/v2" "golang.org/x/crypto/sha3" ) type entropy []byte func New(ms uint64, num int64, salt []byte) (ulid.ULID, error) { if len(salt) > 120 { return ulid.ULID{}, fmt.Errorf("salt len could not be longer than 120 bytes") } e := make(entropy, 8, 128) binary.LittleEndian.PutUint64(e[:8], uint64(num)) e = append(e, salt...) return ulid.New(ms, e) } func (e entropy) Read(p []byte) (n int, err error) { sha3.ShakeSum256(p, e) return len(p), nil }