{"id":25421561,"url":"https://github.com/reecerussell/adaptive-password-hasher","last_synced_at":"2025-09-05T10:34:25.779Z","repository":{"id":45191409,"uuid":"271247139","full_name":"reecerussell/adaptive-password-hasher","owner":"reecerussell","description":"A simple, lightweight, adaptive password hasher for Go, using the pbkdf2 key derivation algorithm.","archived":false,"fork":false,"pushed_at":"2022-01-02T10:56:40.000Z","size":21,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-06T13:41:36.331Z","etag":null,"topics":["go","logging","password-hasher"],"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/reecerussell.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-06-10T10:27:40.000Z","updated_at":"2024-04-20T16:39:22.000Z","dependencies_parsed_at":"2022-08-28T14:11:35.782Z","dependency_job_id":null,"html_url":"https://github.com/reecerussell/adaptive-password-hasher","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/reecerussell/adaptive-password-hasher","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reecerussell%2Fadaptive-password-hasher","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reecerussell%2Fadaptive-password-hasher/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reecerussell%2Fadaptive-password-hasher/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reecerussell%2Fadaptive-password-hasher/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/reecerussell","download_url":"https://codeload.github.com/reecerussell/adaptive-password-hasher/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/reecerussell%2Fadaptive-password-hasher/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273746848,"owners_count":25160647,"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","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["go","logging","password-hasher"],"created_at":"2025-02-16T20:48:58.014Z","updated_at":"2025-09-05T10:34:25.731Z","avatar_url":"https://github.com/reecerussell.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/reecerussell/adaptive-password-hasher)](https://goreportcard.com/badge/github.com/reecerussell/adaptive-password-hasher)\n[![CircleCI](https://circleci.com/gh/reecerussell/adaptive-password-hasher/tree/master.png?style=shield)](https://circleci.com/gh/reecerussell/adaptive-password-hasher/tree/master.png?style=shield)\n[![codecov](https://codecov.io/gh/reecerussell/adaptive-password-hasher/branch/master/graph/badge.svg)](https://codecov.io/gh/reecerussell/adaptive-password-hasher)\n[![Go Docs](https://godoc.org/github.com/reecerussell/adaptive-password-hasher?status.svg)](https://godoc.org/github.com/reecerussell/adaptive-password-hasher)\n\n# Adaptive Password Hasher\n\n\u003cimg src=\"https://media.giphy.com/media/loXfQtPqLxGmbLs9h2/giphy.gif\" align=\"right\" width=\"40%\" alt=\"A super cool gif\" /\u003e\n\nA simple, adaptive, password hashing module for Go!\n\nUsing the pbkdf2 key derivation algorithm, the module has functionality to hash and verify hashes, for a number of different hash algorithms, key and salt sizes. Currently, only the SHA256 and SHA512 hashing functions are supported - more are to come if needed, but feel free to open a PR for another.\n\n## Contents\n\n- [Installation](#installation)\n- [Get Started](#get-started)\n  - [Defaults](#defaults)\n- [Advanced](#advanced)\n  - [Hash Keys](#hash-keys)\n  - [Setup](#setup)\n- [Info](#info)\n\n## \u003cspan id=\"installation\"\u003eInstallation\u003c/span\u003e\n\nInstallation is very simple. By using the Go CLI and `go get` installation can be achieved by running:\n\n    go get -u github.com/reecerussell/adaptive-password-hasher\n    \n## \u003cspan id=\"get-started\"\u003eGet Started\u003c/span\u003e\n\nTo get started, you must first install the package, which you can do [here](#installation).\n\nFirst of all, add the module import:\n\n```go\nimport (\n    hasher \"github.com/reecerussell/adaptive-password-hasher\"\n)\n```\n    \nThen, you can use the exported functions `Hash` and `Verify`. Hashing a password can be done as follows:\n\n```go\npwd := []byte(\"MySuperSecurePassword\")\nhash := hasher.hash(pwd)\n    \n// encode \u0026 print\nfmt.Printf(\"My Hashed Password: %s\\n\", base64.StdEncoding.EncodeToString(hash))\n```    \nSo what if you need to verify it? Easy!\n\n    ok := hasher.Verify(pwd, hash)\n    fmt.Printf(\"Verified: %v\\n\", ok)\n    \nAnd that's it!\n\n### \u003cspan id=\"defaults\"\u003eDefaults\u003c/span\u003e\n\nThese exported functions all use the default hasher interface, meaning they use the default hashing values.\n\n| Default          | Value   | Property             |\n|------------------|---------|----------------------|\n|Iteration Count   | 1000    |DefaultIterationCount |\n|Salt Size         | 128-bit |DefaultSaltSize       |\n|Key Size          | 256-bit |DefaultKeySize        |\n|Hashing Algorithm | SHA256  |DefaultHashKey        |\n\n## \u003cspan id=\"advanced\"\u003eAdvanced\u003c/span\u003e\n\nSo you'd like to change the hashing algorithm or maybe even key size. It's just as simple as using the default functions. By using the `New()` function, you can pass in your own settings. The `New()` function requires 4 parameters: iteration count, salt size, key size and a hashing algorithm key.\n\n### \u003cspan id=\"hash-keys\"\u003eHash Keys\u003c/span\u003e\n\nCurrently, both SHA256 and SHA512 are supported, which means you can use them in your password hasher. Stored as constants, each supported algorithm has a \"hash key\", which make it easy to switch to different hashes and are used to distinguise what hash functions were used for a specific hash.\n\n| Constant   | Algorithm | Value |\n|------------|-----------|-------|\n| HashSHA256 | SHA256    | 1     |\n| HashSHA512 | SHA512    | 2     |\n\n### \u003cspan id=\"setup\"\u003eSetup\u003c/span\u003e\n\nUsing this module with the `New()` function allows a lot more versability by enabling you to customise the hasher to your needs.\n\nHere is an example on how to set it up:\n\n```go\nmyIterationCount := 15000\nmySaltSize := 128\nmyKeySize := 256\nmyHashKey := hasher.HashSHA512\n\nmyHasher, err := hasher.New(myIterationCount, mySaltSize, myKeySize, myHashKey)\nif err != nil {\n    panic(err)\n}\n\n// hash a password\npwd := []byte(\"MySecurePassword\")\nhash := myHasher.Hash([]byte(pwd))\n\n// encode and print\nfmt.Printf(\"Hash: %s\\n\", base64.StdEncoding.EncodeToString(hash))\n\n// verify\nok := myHasher.Verify(pwd, hash)\nfmt.Printf(\"Verified: %v\\n\", ok)\n```\n\nUsing the \"advanced\" method of setting up the hasher, you get the same API and functions as the default method of using it. It's worth noting you can pass in the default constants as arguments to the `New()` function.\n\n## Info\n\nUpdated on 11/06/2020 - Reece\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freecerussell%2Fadaptive-password-hasher","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Freecerussell%2Fadaptive-password-hasher","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Freecerussell%2Fadaptive-password-hasher/lists"}