solsha3

package module
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 31, 2021 License: MIT Imports: 12 Imported by: 0

README


logo


go-solidity-sha3

Generate Solidity SHA3 (Keccak256) hashes in Go.

License Build Status Go Report Card GoDoc PRs Welcome

This package is the Go equivalent of require('ethers').utils.solidityKeccak256 NPM module.

Install

go get github.com/miguelmota/go-solidity-sha3

Documentation

Documentation on GoDoc

Getting started

Simple example:

package main

import (
	"encoding/hex"
	"fmt"

	"github.com/miguelmota/go-solidity-sha3"
)

func main() {
	hash := solsha3.SoliditySHA3(
		// types
		[]string{"address", "uint256"},

		// values
		[]interface{}{
			"0x935F7770265D0797B621c49A5215849c333Cc3ce",
			"100000000000000000",
		},
	)

	fmt.Println(hex.EncodeToString(hash))
}

Output:

0a3844b522d9e3a837ae56d4c57d668feb26325834bf4ba49e153d84ed7ad53d

More complex example:

package main

import (
	"encoding/hex"
	"fmt"

	"github.com/miguelmota/go-solidity-sha3"
)

func main() {
	types := []string{"address", "bytes1", "uint8[]", "bytes32", "uint256", "address[]", "uint32"}
	values := []interface{}{
		"0x935F7770265D0797B621c49A5215849c333Cc3ce",
		"0xa",
		[]uint8{128, 255},
		"0x4e03657aea45a94fc7d47ba826c8d667c0d1e6e33a64a036ec44f58fa12d6c45",
		"100000000000000000",
		[]string{
			"0x13D94859b23AF5F610aEfC2Ae5254D4D7E3F191a",
			"0x473029549e9d898142a169d7234c59068EDcBB33",
		},
		123456789,
	}

	hash := solsha3.SoliditySHA3(types, values)

	fmt.Println(hex.EncodeToString(hash))
}

Output:

ad390a98c1c32cdb1f046f6887a4109f12290b690127e6e15da4ca210235510e

Contributing

Pull requests are welcome!

For contributions please create a new branch and submit a pull request for review.

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Address

func Address(input interface{}) []byte

Address address

func AddressArray

func AddressArray(input interface{}) []byte

AddressArray address

func Bool

func Bool(input interface{}) []byte

Bool bool

func BoolArray

func BoolArray(input interface{}) []byte

BoolArray bool array

func Byte

func Byte(input interface{}) []byte

Byte byte

func Bytes1

func Bytes1(input interface{}) []byte

Bytes1 bytes1

func Bytes10

func Bytes10(input interface{}) []byte

Bytes10 bytes10

func Bytes11

func Bytes11(input interface{}) []byte

Bytes11 bytes11

func Bytes12

func Bytes12(input interface{}) []byte

Bytes12 bytes12

func Bytes13

func Bytes13(input interface{}) []byte

Bytes13 bytes13

func Bytes14

func Bytes14(input interface{}) []byte

Bytes14 bytes14

func Bytes15

func Bytes15(input interface{}) []byte

Bytes15 bytes15

func Bytes16

func Bytes16(input interface{}) []byte

Bytes16 bytes16

func Bytes17

func Bytes17(input interface{}) []byte

Bytes17 bytes17

func Bytes18

func Bytes18(input interface{}) []byte

Bytes18 bytes18

func Bytes19

func Bytes19(input interface{}) []byte

Bytes19 bytes19

func Bytes2

func Bytes2(input interface{}) []byte

Bytes2 bytes2

func Bytes20

func Bytes20(input interface{}) []byte

Bytes20 bytes20

func Bytes21

func Bytes21(input interface{}) []byte

Bytes21 bytes21

func Bytes22

func Bytes22(input interface{}) []byte

Bytes22 bytes22

func Bytes23

func Bytes23(input interface{}) []byte

Bytes23 bytes23

func Bytes24

func Bytes24(input interface{}) []byte

Bytes24 bytes24

func Bytes25

func Bytes25(input interface{}) []byte

Bytes25 bytes25

func Bytes26

func Bytes26(input interface{}) []byte

Bytes26 bytes26

func Bytes27

func Bytes27(input interface{}) []byte

Bytes27 bytes27

func Bytes28

func Bytes28(input interface{}) []byte

Bytes28 bytes28

func Bytes29

func Bytes29(input interface{}) []byte

Bytes29 bytes29

func Bytes3

func Bytes3(input interface{}) []byte

Bytes3 bytes3

func Bytes30

func Bytes30(input interface{}) []byte

Bytes30 bytes30

func Bytes31

func Bytes31(input interface{}) []byte

Bytes31 bytes31

func Bytes32

func Bytes32(input interface{}) []byte

Bytes32 bytes32

func Bytes4

func Bytes4(input interface{}) []byte

Bytes4 bytes4

func Bytes5

func Bytes5(input interface{}) []byte

Bytes5 bytes5

func Bytes6

func Bytes6(input interface{}) []byte

Bytes6 bytes6

func Bytes7

func Bytes7(input interface{}) []byte

Bytes7 bytes7

func Bytes8

func Bytes8(input interface{}) []byte

Bytes8 bytes8

func Bytes9

func Bytes9(input interface{}) []byte

Bytes9 bytes9

func ConcatByteSlices

func ConcatByteSlices(arrays ...[]byte) []byte

ConcatByteSlices concat byte slices

func Int128

func Int128(input interface{}) []byte

Int128 int128

func Int128Array

func Int128Array(input interface{}) []byte

Int128Array int128 array

func Int16

func Int16(input interface{}) []byte

Int16 int16

func Int16Array

func Int16Array(input interface{}) []byte

Int16Array int16 array

func Int256

func Int256(input interface{}) []byte

Int256 int256

func Int256Array

func Int256Array(input interface{}) []byte

Int256Array int256 array

func Int32

func Int32(input interface{}) []byte

Int32 int32

func Int32Array

func Int32Array(input interface{}) []byte

Int32Array int32

func Int64

func Int64(input interface{}) []byte

Int64 int64

func Int64Array

func Int64Array(input interface{}) []byte

Int64Array int64 array

func Int8

func Int8(input interface{}) []byte

Int8 int8

func Int8Array

func Int8Array(input interface{}) []byte

Int8Array int8 array

func Pack

func Pack(types []string, values []interface{}) []byte

Pack ...

func SoliditySHA3

func SoliditySHA3(data ...interface{}) []byte

SoliditySHA3 solidity sha3

func SoliditySHA3WithPrefix

func SoliditySHA3WithPrefix(data []byte) []byte

SoliditySHA3WithPrefix solidity sha3 with prefix

func String

func String(input interface{}) []byte

String string

func StringArray

func StringArray(input interface{}) []byte

StringArray string

func Uint128

func Uint128(input interface{}) []byte

Uint128 uint128

func Uint128Array

func Uint128Array(input interface{}) []byte

Uint128Array uint128

func Uint16

func Uint16(input interface{}) []byte

Uint16 uint16

func Uint16Array

func Uint16Array(input interface{}) []byte

Uint16Array uint16 array

func Uint256

func Uint256(input interface{}) []byte

Uint256 uint256

func Uint256Array

func Uint256Array(input interface{}) []byte

Uint256Array uint256 array

func Uint32

func Uint32(input interface{}) []byte

Uint32 uint32

func Uint32Array

func Uint32Array(input interface{}) []byte

Uint32Array uint32 array

func Uint64

func Uint64(input interface{}) []byte

Uint64 uint64

func Uint64Array

func Uint64Array(input interface{}) []byte

Uint64Array uint64 array

func Uint8

func Uint8(input interface{}) []byte

Uint8 uint8

func Uint8Array

func Uint8Array(input interface{}) []byte

Uint8Array uint8 array

Types

This section is empty.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL