{"id":13684780,"url":"https://github.com/antelle/argon2-browser","last_synced_at":"2025-05-16T05:04:09.823Z","repository":{"id":38325196,"uuid":"66876222","full_name":"antelle/argon2-browser","owner":"antelle","description":"Argon2 library compiled for browser runtime","archived":false,"fork":false,"pushed_at":"2023-03-24T03:35:15.000Z","size":3764,"stargazers_count":404,"open_issues_count":19,"forks_count":84,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-10T02:05:50.881Z","etag":null,"topics":["argon2","hash","kdf","keepass","keeweb","wasm","webassembly"],"latest_commit_sha":null,"homepage":"https://antelle.net/argon2-browser","language":"JavaScript","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/antelle.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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},"funding":{"github":"antelle","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2016-08-29T20:00:27.000Z","updated_at":"2025-05-08T04:07:25.000Z","dependencies_parsed_at":"2024-01-06T12:27:03.820Z","dependency_job_id":"15d1774f-c8f3-4b06-9efa-b2fc5f425074","html_url":"https://github.com/antelle/argon2-browser","commit_stats":{"total_commits":192,"total_committers":9,"mean_commits":"21.333333333333332","dds":0.05208333333333337,"last_synced_commit":"d73916b8efad2ef47140a52acd48b166a4ba97bf"},"previous_names":[],"tags_count":37,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antelle%2Fargon2-browser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antelle%2Fargon2-browser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antelle%2Fargon2-browser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antelle%2Fargon2-browser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antelle","download_url":"https://codeload.github.com/antelle/argon2-browser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254471061,"owners_count":22076585,"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":["argon2","hash","kdf","keepass","keeweb","wasm","webassembly"],"created_at":"2024-08-02T14:00:38.691Z","updated_at":"2025-05-16T05:04:09.780Z","avatar_url":"https://github.com/antelle.png","language":"JavaScript","funding_links":["https://github.com/sponsors/antelle"],"categories":["JavaScript","Projects","Libraries","C","Security"],"sub_categories":["Others","Web","Video"],"readme":"# Argon2 in browser ![Build](https://github.com/antelle/argon2-browser/workflows/Build/badge.svg)\n\nArgon2 is a password-hashing function, the winner of Password Hashing Competition. Here Argon2 library is compiled for browser runtime.\n\n[Live demo](https://antelle.github.io/argon2-browser)\n\n[More about Argon2](https://github.com/P-H-C/phc-winner-argon2)\n\n[Usage](#usage)\n\n## The numbers\n\n|                   | Time, ms (lower is better) |\n|-------------------|----------------------------|\n| Chrome WASM       | 225                        |\n| Chrome WASM+SIMD  | 119                        |\n| Firefox WASM      | 195                        |\n| Firefox WASM+SIMD | 135                        |\n| Safari WASM       | 174                        |\n| Native -O3 SSE    |  15                        |\n| Native -O3        |  42                        |\n| Native -O1        |  55                        |\n| Native -O0        | 395                        |\n\n## Test Environment\n\nEnvironment used to get the numbers above:\n\nAlgorithm parameters (`-d -t 100 -m 10 -p 1`):\n- iterations: 100\n- memory: 1MiB (1024 KiB)\n- hash length: 32\n- parallelism: 1\n- argon2d\n\nEnvironment:\n\n- MacBook pro 2020, Intel Core i7, 2.3GHz (x64), macOS 10.14.6 (18G95)\n- Chrome 85.0.4183.83 (Official Build)\n- Firefox 80.0.1\n- Safari 13.1.2 (15609.3.5.1.3)\n- native argon2 compiled from https://github.com/P-H-C/phc-winner-argon2 @440ceb9\n\n## Code size\n\n`ll -h dist`\n\n| File        | Code size, kB |\n|-------------|---------------|\n| argon2.js   | 14            |\n| argon2.wasm | 25            |\n\n## Is Argon2 modified?\n\nNo, it's used a submodule from upstream.\n\n## SIMD\n\nSIMD is not quite here in WebAssembly, however for those who would like to give it a try,\nwe already provide a working build with SIMD. At the moment it works only in Chrome,\nto be able to use it, you need to either add\n[this origin trial](https://developers.chrome.com/origintrials/#/view_trial/-4708513410415853567) to your website,\nor enable the SIMD feature in Chrome flags.\n\nMore about WebAssembly SIMD support in V8: https://v8.dev/features/simd\n\nOn Firefox you need to enable `javascript.options.wasm_simd` option in about:config.\n\nTo use the SIMD version, load `argon2-simd.wasm` instead of `argon2.wasm`.\n\n## JS Library\n\nThe library can be installed from npm:\n```bash\nnpm install argon2-browser\n```\n\nThen add this script to your HTML or use your favorite bundler:\n```html\n\u003cscript src=\"node_modules/argon2-browser/lib/argon2.js\"\u003e\u003c/script\u003e\n```\n\nAlternatively, you can use the bundled version, this way you can include just one script:\n```html\n\u003cscript src=\"node_modules/argon2-browser/dist/argon2-bundled.js\"\u003e\u003c/script\u003e\n```\n\nCalculate the hash:\n```javascript\nargon2.hash({ pass: 'password', salt: 'somesalt' })\n    .then(h =\u003e console.log(h.hash, h.hashHex, h.encoded))\n    .catch(e =\u003e console.error(e.message, e.code))\n```\n\nVerify the encoded hash (if you need it):\n```javascript\nargon2.verify({ pass: 'password', encoded: 'enc-hash' })\n    .then(() =\u003e console.log('OK'))\n    .catch(e =\u003e console.error(e.message, e.code))\n```\n\nOther parameters:\n```javascript\nargon2.hash({\n    // required\n    pass: 'password',\n    salt: 'salt',\n    // optional\n    time: 1, // the number of iterations\n    mem: 1024, // used memory, in KiB\n    hashLen: 24, // desired hash length\n    parallelism: 1, // desired parallelism (it won't be computed in parallel, however)\n    secret: new Uint8Array([...]), // optional secret data\n    ad: new Uint8Array([...]), // optional associated data\n    type: argon2.ArgonType.Argon2d, // Argon2d, Argon2i, Argon2id\n})\n// result\n.then(res =\u003e {\n    res.hash // hash as Uint8Array\n    res.hashHex // hash as hex-string\n    res.encoded // encoded hash, as required by argon2\n})\n// or error\n.catch(err =\u003e {\n    err.message // error message as string, if available\n    err.code // numeric error code\n})\n```\n\n```javascript\nargon2.verify({\n    // required\n    pass: 'password',\n    encoded: 'enc-hash',\n    // optional\n    secret: new Uint8Array([...]), // optional secret data\n    ad: new Uint8Array([...]), // optional associated data\n    type: argon2.ArgonType.Argon2d, // Argon2d, Argon2i, Argon2id. default: guess\n})\n// result\n.then(res =\u003e {\n    res.hash // hash as Uint8Array\n    res.hashHex // hash as hex-string\n    res.encoded // encoded hash, as required by argon2\n})\n// or error\n.catch(err =\u003e {\n    err.message // error message as string, if available\n    err.code // numeric error code\n})\n```\n\n## Usage\n\nYou can use this module in several ways: \n\n1. write the WASM loader manually, for example, if you need more control over memory ([example](docs/js/calc.js));\n2. bundle it with WebPack or another bundler ([example](examples/webpack));\n3. in vanilla js: [example](examples/vanilla);\n4. in node.js: [example](examples/node) (see a note below).\n\n## Bundlers\n\n- WebPack: [examples/webpack](https://github.com/antelle/argon2-browser/tree/master/examples/webpack)\n- create-react-app: [examples/react](https://github.com/antelle/argon2-browser/tree/master/examples/react). Derived from [#38](https://github.com/antelle/argon2-browser/issues/38#issuecomment-749690581)\n\n## Node.js support\n\nOf course you [can use](examples/node) generated WASM in node.js, but it's not sensible: you will get much better speed by compiling it as a native node.js addon, which is not that hard. Wait, it's already done, just install [this package](https://github.com/ranisalt/node-argon2).\n\n## Is it used anywhere?\n\nIt is! [KeeWeb](https://github.com/keeweb/keeweb) (web-based password manager) is using it as a password hashing function implementation.\n[Check out the source code](https://github.com/keeweb/keeweb/blob/develop/app/scripts/util/kdbxweb/kdbxweb-init.js#L11), if you're interested.\n\n## Building\n\nYou can build everything with\n```bash\n./build.sh\n```\n\nPrerequisites:\n- emscripten with WebAssembly support ([howto](http://webassembly.org/getting-started/developers-guide/))\n- CMake\n\n## License\n\n[MIT](https://opensource.org/licenses/MIT)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantelle%2Fargon2-browser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantelle%2Fargon2-browser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantelle%2Fargon2-browser/lists"}