{"id":19339738,"url":"https://github.com/rubenv/pwcrypto","last_synced_at":"2025-07-17T16:03:20.778Z","repository":{"id":66156189,"uuid":"191709481","full_name":"rubenv/pwcrypto","owner":"rubenv","description":"Go library with password cryptography routines","archived":false,"fork":false,"pushed_at":"2023-08-30T19:37:16.000Z","size":25,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-24T08:27:08.029Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/rubenv.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}},"created_at":"2019-06-13T07:05:04.000Z","updated_at":"2023-08-30T19:07:53.000Z","dependencies_parsed_at":"2024-06-20T17:32:27.837Z","dependency_job_id":null,"html_url":"https://github.com/rubenv/pwcrypto","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/rubenv/pwcrypto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpwcrypto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpwcrypto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpwcrypto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpwcrypto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rubenv","download_url":"https://codeload.github.com/rubenv/pwcrypto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rubenv%2Fpwcrypto/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265625568,"owners_count":23800624,"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-11-10T03:23:39.588Z","updated_at":"2025-07-17T16:03:20.752Z","avatar_url":"https://github.com/rubenv.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pwcrypto\n\n\u003e Go library with password cryptography routines\n\n[![test](https://github.com/rubenv/pwcrypto/actions/workflows/test.yml/badge.svg)](https://github.com/rubenv/pwcrypto/actions/workflows/test.yml) [![GoDoc](https://godoc.org/github.com/rubenv/pwcrypto?status.png)](https://godoc.org/github.com/rubenv/pwcrypto)\n\nThis library provides routines for securly storing passwords in a database and validating them.\n\nFeatures:\n\n- All passwords stored with one-way hashes\n- Unique salts per user\n- Upgradable cryptography algorithms and hash strengths\n- Indicates when passwords should be rehashed to gradually upgrade password cryptography\n- Configurable hashing routines\n\n## Usage\n\nCreate a `Crypto` object, which will hold the cryptography routines used. Pass\nthe algorithms you wish to use as arguments. The first algorithm will be used\nfor storing passwords, the other algorithms are accepted for existing passwords\n(see `Password Upgrades` below).\n\n```\npasswords := pwcrypto.New(\n    NewArgon2Crypto(),\n    NewScryptCrypto(),\n    NewPBKDF2Crypto(),\n    NewSHA256Crypto(),\n)\n```\n\nUse `Hash()` when storing a password for a user:\n\n```\nhash, err := passwords.Hash(\"mySecurePassword\")\n```\n\nThe value of `hash` is a string containing the hashed password and a set of\nconfiguration parameters used for verifying the password. Store this string in\nyour database.\n\nUse `Check()` for validating passwords:\n\n```\nvalid, mustUpgrade, err := passwords.Check(\"someUserInput\", hash)\n```\n\nIn the above:\n\n- `hash` is the value you previously stored in your database, look it up for the user trying to authenticate\n- `\"someUserInput\"` is the password entered during login\n- `valid` indicates whether the input is correct\n- `mustUpgrade` indicates that the password needs to be upgraded (see below).\n\n## Password Upgrades\n\nDuring check, `mustUpgrade` will be `true` if the database hash uses an\noutdated hash. In this case you should use `Hash()` again with the user input\nand store the new hashed value in your database.\n\nThis allows you to to upgrade your database gradually. Suppose you previously\nused `SHA1`, but want to upgrade to `SHA256`. Just configure pwcrypto with\n`SHA256` as the primary algorithm and `SHA1` as the fallback algorithm.\n\n```\npasswords := pwcrypto.New(\n    NewSHA256Crypto(),\n    NewSHA1Crypto(),\n)\n```\n\nWhenever a user logs in correctly, you'll receive `mustUpgrade == true`. At\nthis point you can use the user input to re-hash the password, which will then\nuse `SHA256`.\n\n## Configuring hashing algorithms\n\nBy default, the unparametrized algorithm constructor will return a\nbest-practices version of the algorithm.\n\nYou can use the more verbose constructor to override specific options (if any).\n\n### PBKDF2\n\n- Default: `NewPBKDF2Crypto()`\n- Verbose: `NewPBKDF2CryptoWithOptions(iter, keyLen, saltLen int, hashFns []HashFunction)`\n\nAllows you to override the number of iterations, key length, salt length and\nhashing functions (for HMAC). Similar to crypto algorithms, the first hash\nfunction is preferred, others are for fallback compatibility.\n\n### Scrypt\n\n- Default: `NewScryptCrypto()`\n- Verbose: `NewScryptCryptoWithOptions(saltLen, cpuMemCost, r, p, keyLen int)`\n\n### Argon2\n\n- Default: `NewArgon2Crypto()`\n- Verbose: `NewArgon2CryptoWithOptions(saltLen int, time, memory uint32, threads uint8, keyLen uint32)`\n\n## License\n\nThis library is distributed under the [MIT](LICENSE) license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenv%2Fpwcrypto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frubenv%2Fpwcrypto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frubenv%2Fpwcrypto/lists"}