Revision 73795210a4490f42c2d1be1ef63420f67ca29dc0 authored by Thane Thomson on 21 December 2022, 22:48:02 UTC, committed by GitHub on 21 December 2022, 22:48:02 UTC
* docs: Update upgrading guidelines with new ABCI version

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* docs: Fix broken link in upgrading guidelines for ABCI++

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* docs: Prepare version in upgrading guidelines

Signed-off-by: Thane Thomson <connect@thanethomson.com>

* Update UPGRADING.md

Co-authored-by: Sergio Mena <sergio@informal.systems>

Signed-off-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: Sergio Mena <sergio@informal.systems>
1 parent 37cb51c
Raw File
random.go
package crypto

import (
	crand "crypto/rand"
	"encoding/hex"
	"io"
)

// This only uses the OS's randomness
func randBytes(numBytes int) []byte {
	b := make([]byte, numBytes)
	_, err := crand.Read(b)
	if err != nil {
		panic(err)
	}
	return b
}

// This only uses the OS's randomness
func CRandBytes(numBytes int) []byte {
	return randBytes(numBytes)
}

// CRandHex returns a hex encoded string that's floor(numDigits/2) * 2 long.
//
// Note: CRandHex(24) gives 96 bits of randomness that
// are usually strong enough for most purposes.
func CRandHex(numDigits int) string {
	return hex.EncodeToString(CRandBytes(numDigits / 2))
}

// Returns a crand.Reader.
func CReader() io.Reader {
	return crand.Reader
}
back to top