{"id":13613914,"url":"https://github.com/multiformats/go-multihash","last_synced_at":"2025-05-14T06:14:31.599Z","repository":{"id":17314348,"uuid":"20085120","full_name":"multiformats/go-multihash","owner":"multiformats","description":"Multihash implementation in Go","archived":false,"fork":false,"pushed_at":"2025-04-15T00:41:34.000Z","size":288,"stargazers_count":240,"open_issues_count":17,"forks_count":59,"subscribers_count":24,"default_branch":"master","last_synced_at":"2025-04-15T08:45:09.326Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/multiformats.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2014-05-23T03:06:46.000Z","updated_at":"2025-04-15T00:41:36.000Z","dependencies_parsed_at":"2023-01-13T19:16:18.965Z","dependency_job_id":"6c23bc21-8da3-4357-bdef-23e629f65306","html_url":"https://github.com/multiformats/go-multihash","commit_stats":{"total_commits":233,"total_committers":34,"mean_commits":6.852941176470588,"dds":0.8068669527896996,"last_synced_commit":"2a742b0292468ea87dcb5f7649328e183c5c86fa"},"previous_names":["jbenet/go-multihash"],"tags_count":34,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiformats%2Fgo-multihash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiformats%2Fgo-multihash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiformats%2Fgo-multihash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/multiformats%2Fgo-multihash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/multiformats","download_url":"https://codeload.github.com/multiformats/go-multihash/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254083932,"owners_count":22011905,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T20:00:54.779Z","updated_at":"2025-05-14T06:14:31.568Z","avatar_url":"https://github.com/multiformats.png","language":"Go","funding_links":[],"categories":["开源类库","Open source library","Go"],"sub_categories":["算法","Algorithm"],"readme":"# go-multihash\n\n[![](https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square)](http://ipn.io)\n[![](https://img.shields.io/badge/project-multiformats-blue.svg?style=flat-square)](https://github.com/multiformats/multiformats)\n[![](https://img.shields.io/badge/freenode-%23ipfs-blue.svg?style=flat-square)](https://webchat.freenode.net/?channels=%23ipfs)\n[![](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/RichardLitt/standard-readme)\n[![GoDoc](https://godoc.org/github.com/multiformats/go-multihash?status.svg)](https://godoc.org/github.com/multiformats/go-multihash)\n[![Travis CI](https://img.shields.io/travis/multiformats/go-multihash.svg?style=flat-square\u0026branch=master)](https://travis-ci.org/multiformats/go-multihash)\n[![codecov.io](https://img.shields.io/codecov/c/github/multiformats/go-multihash.svg?style=flat-square\u0026branch=master)](https://codecov.io/github/multiformats/go-multihash?branch=master)\n\n\u003e [multihash](https://github.com/multiformats/multihash) implementation in Go\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [Maintainers](#maintainers)\n- [Contribute](#contribute)\n- [License](#license)\n\n## Install\n\n`go-multihash` is a standard Go module which can be installed with:\n\n```sh\ngo get github.com/multiformats/go-multihash\n```\n\n## Usage\n\n\n### Example\n\nThis example takes a standard hex-encoded data and uses `EncodeName` to calculate the SHA1 multihash value for the buffer.\n\nThe resulting hex-encoded data corresponds to: `\u003chash function code\u003e\u003cdigest size\u003e\u003chash function output\u003e`, which could be re-parsed\nwith `Multihash.FromHexString()`.\n\n\n```go\npackage main\n\nimport (\n\t\"encoding/hex\"\n\t\"fmt\"\n\n\t\"github.com/multiformats/go-multihash\"\n)\n\nfunc main() {\n\t// ignores errors for simplicity.\n\t// don't do that at home.\n\t// Decode a SHA1 hash to a binary buffer\n\tbuf, _ := hex.DecodeString(\"0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33\")\n\n\t// Create a new multihash with it.\n\tmHashBuf, _ := multihash.EncodeName(buf, \"sha1\")\n\t// Print the multihash as hex string\n\tfmt.Printf(\"hex: %s\\n\", hex.EncodeToString(mHashBuf))\n\n\t// Parse the binary multihash to a DecodedMultihash\n\tmHash, _ := multihash.Decode(mHashBuf)\n\t// Convert the sha1 value to hex string\n\tsha1hex := hex.EncodeToString(mHash.Digest)\n\t// Print all the information in the multihash\n\tfmt.Printf(\"obj: %v 0x%x %d %s\\n\", mHash.Name, mHash.Code, mHash.Length, sha1hex)\n}\n```\n\nTo run, copy to [example/foo.go](example/foo.go) and:\n\n```\n\u003e cd example/\n\u003e go build\n\u003e ./example\nhex: 11140beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33\nobj: sha1 0x11 20 0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33\n```\n\n## Contribute\n\nContributions welcome. Please check out [the issues](https://github.com/multiformats/go-multihash/issues).\n\nCheck out our [contributing document](https://github.com/multiformats/multiformats/blob/master/contributing.md) for more information on how we work, and about contributing in general. Please be aware that all interactions related to multiformats are subject to the IPFS [Code of Conduct](https://github.com/ipfs/community/blob/master/code-of-conduct.md).\n\nSmall note: If editing the README, please conform to the [standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n## License\n\n[MIT](LICENSE) © 2014 Juan Batiz-Benet\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiformats%2Fgo-multihash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmultiformats%2Fgo-multihash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmultiformats%2Fgo-multihash/lists"}