
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
github.com/immutable/go-solidity-sha3
Generate Solidity SHA3 (Keccak256) hashes in Go.
This package is the Go equivalent of require('ethers').utils.solidityKeccak256
NPM module.
go get github.com/miguelmota/go-solidity-sha3
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
Pull requests are welcome!
For contributions please create a new branch and submit a pull request for review.
MIT
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.