Simplify codebase per audit of 8b89f14
This commit is contained in:
@@ -2,9 +2,6 @@ package ids
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"crypto/sha256"
|
||||
"encoding/binary"
|
||||
"strings"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -25,7 +22,6 @@ const (
|
||||
Blob Prefix = "blb"
|
||||
LeadNote Prefix = "not"
|
||||
WorkflowDefinition Prefix = "wfd"
|
||||
WorkflowRun Prefix = "run"
|
||||
Send Prefix = "snd"
|
||||
Client Prefix = "cli"
|
||||
ClientRequest Prefix = "req"
|
||||
@@ -48,14 +44,3 @@ func New(prefix Prefix) string {
|
||||
}
|
||||
return string(prefix) + string(out)
|
||||
}
|
||||
|
||||
func Derive(prefix Prefix, parts ...string) string {
|
||||
sum := sha256.Sum256([]byte(strings.Join(parts, "\x00")))
|
||||
n := binary.BigEndian.Uint64(sum[:8])
|
||||
out := make([]byte, randomLength)
|
||||
for i := range out {
|
||||
out[i] = alphabet[n%uint64(len(alphabet))]
|
||||
n /= uint64(len(alphabet))
|
||||
}
|
||||
return string(prefix) + string(out)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user