{"id":20187305,"url":"https://github.com/anaskhan96/go-password-encoder","last_synced_at":"2025-05-08T04:25:24.632Z","repository":{"id":43076630,"uuid":"94994271","full_name":"anaskhan96/go-password-encoder","owner":"anaskhan96","description":"Go package to encode (with random generated salt) and verify passwords","archived":false,"fork":false,"pushed_at":"2020-10-10T21:06:02.000Z","size":14,"stargazers_count":149,"open_issues_count":0,"forks_count":14,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T17:07:48.925Z","etag":null,"topics":["encoding","go","golang","hash","pbkdf2"],"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/anaskhan96.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":"2017-06-21T10:51:40.000Z","updated_at":"2025-01-13T11:48:51.000Z","dependencies_parsed_at":"2022-08-12T10:11:38.180Z","dependency_job_id":null,"html_url":"https://github.com/anaskhan96/go-password-encoder","commit_stats":null,"previous_names":["anaskhan96/go-password-encryptor"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anaskhan96%2Fgo-password-encoder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anaskhan96%2Fgo-password-encoder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anaskhan96%2Fgo-password-encoder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/anaskhan96%2Fgo-password-encoder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/anaskhan96","download_url":"https://codeload.github.com/anaskhan96/go-password-encoder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252998218,"owners_count":21837973,"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":["encoding","go","golang","hash","pbkdf2"],"created_at":"2024-11-14T03:22:41.035Z","updated_at":"2025-05-08T04:25:24.605Z","avatar_url":"https://github.com/anaskhan96.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# go-password-encoder\n[![Build Status](https://travis-ci.org/anaskhan96/go-password-encoder.svg?branch=master)](https://travis-ci.org/anaskhan96/go-password-encoder)\n[![GoDoc](https://godoc.org/github.com/anaskhan96/go-password-encoder?status.svg)](https://pkg.go.dev/github.com/anaskhan96/go-password-encoder)\n[![Go Report Card](https://goreportcard.com/badge/github.com/anaskhan96/go-password-encoder)](https://goreportcard.com/report/github.com/anaskhan96/go-password-encoder)\n\nThis package in Go provides functions to encode a raw password (example, during registration on a site), and later verify it (example, while logging in to the site).\n\nFunctions available:\n```go\nfunc Encode(string, *Options) (string, string) {} // takes the raw password along with options, returns generated salt and hex encoded password\nfunc Verify(string, string, string, *Options) bool {} // takes the raw password, the generated salt, and encoded password with options, and returns true or false\n```\n\nThe `Options` struct is used to enable custom options:\n```go\ntype Options struct {\n\tSaltLen      int\n\tIterations   int\n\tKeyLen       int\n\tHashFunction func() hash.Hash\n}\n```\nPassing `nil` as the last argument in either function resorts to using the default options. The default options are as follows:\n* Length of generated `salt` for the user is `256`\n* Iteration count in [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2) function is `10000`\n* Length of encoded key in [PBKDF2](https://en.wikipedia.org/wiki/PBKDF2) function is `512`\n* Hash algorithm used is `sha512`\n\nHover over to [Usage](#usage) for a complete example.\n\n### Installation\n\n```bash\ngo get github.com/anaskhan96/go-password-encoder\n```\n\nRun `go test` in the package's directory to run tests.\n\n### Usage\n\nFollowing is an example depicting the usage of this package:\n\n```go\npackage main\n\nimport (\n\t\"crypto/md5\"\n\t\"fmt\"\n\t\"github.com/anaskhan96/go-password-encoder\"\n)\n\nfunc main() {\n\t// Using the default options\n\tsalt, encodedPwd := password.Encode(\"generic password\", nil)\n\tcheck := password.Verify(\"generic password\", salt, encodedPwd, nil)\n\tfmt.Println(check) // true\n\n\t// Using custom options\n\toptions := \u0026password.Options{10, 10000, 50, md5.New}\n\tsalt, encodedPwd = password.Encode(\"generic password\", options)\n\tcheck = password.Verify(\"generic password\", salt, encodedPwd, options)\n\tfmt.Println(check) // true\n}\n\n```\n\n### Related\n* [node-password-encrypter](https://github.com/giovanniRodighiero/node-password-encrypter)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanaskhan96%2Fgo-password-encoder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fanaskhan96%2Fgo-password-encoder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fanaskhan96%2Fgo-password-encoder/lists"}