{"id":24390769,"url":"https://github.com/indrasaputra/hashids","last_synced_at":"2025-06-10T13:03:40.367Z","repository":{"id":51029975,"uuid":"302868433","full_name":"indrasaputra/hashids","owner":"indrasaputra","description":"Golang ID to Hash converter using Hashids algorithm.","archived":false,"fork":false,"pushed_at":"2021-05-25T22:44:44.000Z","size":19,"stargazers_count":3,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-29T13:11:12.506Z","etag":null,"topics":["hacktoberfest","hacktoberfest-accepted","hashid","hashids"],"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/indrasaputra.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}},"created_at":"2020-10-10T09:45:37.000Z","updated_at":"2024-03-22T07:20:23.000Z","dependencies_parsed_at":"2022-09-26T16:30:25.744Z","dependency_job_id":null,"html_url":"https://github.com/indrasaputra/hashids","commit_stats":null,"previous_names":["indrasaputra/hashid"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indrasaputra%2Fhashids","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indrasaputra%2Fhashids/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indrasaputra%2Fhashids/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/indrasaputra%2Fhashids/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/indrasaputra","download_url":"https://codeload.github.com/indrasaputra/hashids/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249795193,"owners_count":21326776,"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":["hacktoberfest","hacktoberfest-accepted","hashid","hashids"],"created_at":"2025-01-19T16:34:52.235Z","updated_at":"2025-04-19T20:38:51.032Z","avatar_url":"https://github.com/indrasaputra.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hashids\n\n[![Go Report Card](https://goreportcard.com/badge/github.com/indrasaputra/hashids)](https://goreportcard.com/report/github.com/indrasaputra/hashids)\n[![Workflow](https://github.com/indrasaputra/hashids/workflows/Test/badge.svg)](https://github.com/indrasaputra/hashids/actions)\n[![codecov](https://codecov.io/gh/indrasaputra/hashids/branch/main/graph/badge.svg)](https://codecov.io/gh/indrasaputra/hashids)\n[![Maintainability](https://api.codeclimate.com/v1/badges/2cd8202174459c1b5348/maintainability)](https://codeclimate.com/github/indrasaputra/hashids/maintainability)\n[![Quality Gate Status](https://sonarcloud.io/api/project_badges/measure?project=indrasaputra_hashids\u0026metric=alert_status)](https://sonarcloud.io/dashboard?id=indrasaputra_hashids)\n[![Go Reference](https://pkg.go.dev/badge/github.com/indrasaputra/hashids.svg)](https://pkg.go.dev/github.com/indrasaputra/hashids)\n\nHashids is a package to convert ID into a random string to obfuscate the real ID from user.\nIn the implementation itself, the ID will still be an integer. But, when it is shown to the user,\nit becomes a random string. The generated random string can be decoded back to the original ID.\nThis project uses [https://github.com/speps/go-hashids](https://github.com/speps/go-hashids) as the backend.\n\n## Installation\n\n```\ngo get github.com/indrasaputra/hashids\n```\n\n## Example\n\nLet there be a struct:\n\n```go\ntype Product struct {\n    ID      hashids.ID  `json:\"id\"`\n    Name    string      `json:\"name\"`\n}\n```\n\nThen we have an instance of Product like this:\n\n```go\nproduct := \u0026Product{\n    ID: hashids.ID(66),\n    Name: \"Product's name\",\n}\n```\n\nWhen the `product` is marshalled into a JSON, the ID will not be a plain integer. It will become a random string like this:\n\n```json\n{\n    \"id\": \"kmzwa8awaa\",\n    \"name\": \"product's name\"\n}\n```\n\nUpon decoding the ID, Hashids will decode back the random string to the original ID.\n\n```go\nvar product Product\nb := []byte(`{\"id\": \"kmzwa8awaa\",\"name\": \"product's name\"}`)\njson.Unmarshal(b, \u0026product)\n```\n\nThe code above will fill the product's attributes like this:\n\n```cmd\n{66 product's name}\n```\n\n## Limitation\n\nFor now, this package only support encoding to JSON, decoding from JSON, and encode as a string.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findrasaputra%2Fhashids","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Findrasaputra%2Fhashids","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Findrasaputra%2Fhashids/lists"}