2 //sed -e 's/_N_/Hash/g' -e 's/_S_/32/g' -e '1d' types_template.go | gofmt -w hash.go
10 func BytesTo_N_(b []byte) _N_ {
15 func StringTo_N_(s string) _N_ { return BytesTo_N_([]byte(s)) }
16 func BigTo_N_(b *big.Int) _N_ { return BytesTo_N_(b.Bytes()) }
17 func HexTo_N_(s string) _N_ { return BytesTo_N_(FromHex(s)) }
19 // Don't use the default 'String' method in case we want to overwrite
21 // Get the string representation of the underlying hash
22 func (h _N_) Str() string { return string(h[:]) }
23 func (h _N_) Bytes() []byte { return h[:] }
24 func (h _N_) Big() *big.Int { return Bytes2Big(h[:]) }
25 func (h _N_) Hex() string { return "0x" + Bytes2Hex(h[:]) }
27 // Sets the hash to the value of b. If b is larger than len(h) it will panic
28 func (h *_N_) SetBytes(b []byte) {
29 // Use the right most bytes
35 for i := len(b) - 1; i >= 0; i-- {
36 h[_S_-len(b)+i] = b[i]
40 // Set string `s` to h. If s is larger than len(h) it will panic
41 func (h *_N_) SetString(s string) { h.SetBytes([]byte(s)) }
44 func (h *_N_) Set(other _N_) {
45 for i, v := range other {