github.com/unicornultrafoundation/go-u2u@v1.0.0-rc1.0.20240205080301-e74a83d3fadc/utils/uint2hash.go (about) 1 package utils 2 3 import ( 4 "math/big" 5 6 "github.com/unicornultrafoundation/go-u2u/common" 7 ) 8 9 // BigTo256 converts big number to 32 bytes array 10 func BigTo256(b *big.Int) common.Hash { 11 return common.BytesToHash(b.Bytes()) 12 } 13 14 // U64to256 converts uint64 to 32 bytes array 15 func U64to256(u64 uint64) common.Hash { 16 return BigTo256(new(big.Int).SetUint64(u64)) 17 } 18 19 // U64toBig converts uint64 to big number 20 func U64toBig(u64 uint64) *big.Int { 21 return new(big.Int).SetUint64(u64) 22 } 23 24 // I64to256 converts int64 to 32 bytes array 25 func I64to256(i64 int64) common.Hash { 26 return BigTo256(new(big.Int).SetInt64(i64)) 27 }