Skip to content

BytesToBig

Converts a byte slice to a big.Int.

Function Signature

func BytesToBig(bytes []byte) *big.Int

Source: 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

  1. Converting received binary data to numeric form.
  2. Processing byte arrays from hash functions or signatures.
  3. Converting network byte order data to integers.

See Also