Nonce generates a random n-byte slice
(length int)
| 9 | |
| 10 | // Nonce generates a random n-byte slice |
| 11 | func Nonce(length int) ([]byte, error) { |
| 12 | b := make([]byte, length) |
| 13 | _, err := rand.Read(b) |
| 14 | if err != nil { |
| 15 | return nil, err |
| 16 | } |
| 17 | return b, nil |
| 18 | } |
| 19 | |
| 20 | // HashNonce returns the SHA256 hash of a nonce |
| 21 | func HashNonce(nonce []byte) string { |