aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/sandbox/testdata/sum.go
blob: e4e8643acaa5e26d6ff34fa2f9451b775e8f52eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
//go:build testsuite || tester

package testdata

import (
	"crypto/sha512"
	"encoding/base64"
	"strconv"
)

// sum decodes s as [base64.StdEncoding] and panics if it is invalid or
// unexpectedly sized.
func sum(s string) [sha512.Size]byte {
	p, err := base64.StdEncoding.DecodeString(s)
	if err != nil {
		panic(err)
	}
	if len(p) != sha512.Size {
		panic("unexpected checksum sized " + strconv.Itoa(len(p)))
	}
	return ([sha512.Size]byte)(p)
}