BytesToBig
Converts a byte slice to a big.Int.
Function Signature
func BytesToBig(bytes []byte) *big.IntSource: keccak.go
Parameters
bytes- The byte slice to be converted
Returns
*big.Int- The converted big integer value
Usage Example
package main
import (
"fmt"
"github.com/NethermindEth/starknet.go/utils"
)
func main() {
// Convert byte slice to big.Int
bytes := []byte{0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF}
bigInt := utils.BytesToBig(bytes)
fmt.Printf("Bytes: %x\n", bytes)
fmt.Printf("Big Int: %s\n", bigInt.String())
// Output:
// Bytes: 0123456789abcdef
// Big Int: 81985529216486895
}Common Use Cases
- Converting received binary data to numeric form.
- Processing byte arrays from hash functions or signatures.
- Converting network byte order data to integers.
See Also
- Type Conversions demonstrates byte-to-number conversions

