[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6542":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":16,"stars7d":17,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":16,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":23,"hasPages":21,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":25,"readmeContent":26,"aiSummary":27,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":28,"discoverSource":29},6542,"phc-winner-argon2","P-H-C\u002Fphc-winner-argon2","P-H-C","The password hash Argon2, winner of PHC ","",null,"C",5298,452,119,57,0,2,17,38.97,"Other",false,"master",true,[],"2026-06-12 02:01:26","# Argon2\n\n[![Build Status](https:\u002F\u002Ftravis-ci.org\u002FP-H-C\u002Fphc-winner-argon2.svg?branch=master)](https:\u002F\u002Ftravis-ci.org\u002FP-H-C\u002Fphc-winner-argon2)\n[![Build status](https:\u002F\u002Fci.appveyor.com\u002Fapi\u002Fprojects\u002Fstatus\u002F8nfwuwq55sgfkele?svg=true)](https:\u002F\u002Fci.appveyor.com\u002Fproject\u002FP-H-C\u002Fphc-winner-argon2)\n[![codecov.io](https:\u002F\u002Fcodecov.io\u002Fgithub\u002FP-H-C\u002Fphc-winner-argon2\u002Fcoverage.svg?branch=master)](https:\u002F\u002Fcodecov.io\u002Fgithub\u002FP-H-C\u002Fphc-winner-argon2?branch=master)\n\nThis is the reference C implementation of Argon2, the password-hashing\nfunction that won the [Password Hashing Competition\n(PHC)](https:\u002F\u002Fpassword-hashing.net).\n\nArgon2 is a password-hashing function that summarizes the state of the\nart in the design of memory-hard functions and can be used to hash\npasswords for credential storage, key derivation, or other applications.\n\nIt has a simple design aimed at the highest memory filling rate and\neffective use of multiple computing units, while still providing defense\nagainst tradeoff attacks (by exploiting the cache and memory organization\nof the recent processors).\n\nArgon2 has three variants: Argon2i, Argon2d, and Argon2id. Argon2d is faster\nand uses data-depending memory access, which makes it highly resistant\nagainst GPU cracking attacks and suitable for applications with no threats\nfrom side-channel timing attacks (eg. cryptocurrencies). Argon2i instead\nuses data-independent memory access, which is preferred for password\nhashing and password-based key derivation, but it is slower as it makes\nmore passes over the memory to protect from tradeoff attacks. Argon2id is a\nhybrid of Argon2i and Argon2d, using a combination of data-depending and\ndata-independent memory accesses, which gives some of Argon2i's resistance to\nside-channel cache timing attacks and much of Argon2d's resistance to GPU\ncracking attacks.\n\nArgon2i, Argon2d, and Argon2id are parametrized by:\n\n* A **time** cost, which defines the amount of computation realized and\n  therefore the execution time, given in number of iterations\n* A **memory** cost, which defines the memory usage, given in kibibytes\n* A **parallelism** degree, which defines the number of parallel threads\n\nThe [Argon2 document](argon2-specs.pdf) gives detailed specs and design\nrationale.\n\nPlease report bugs as issues on this repository.\n\n## Usage\n\n`make` builds the executable `argon2`, the static library `libargon2.a`,\nand the shared library `libargon2.so` (or on macOS, the dynamic library\n`libargon2.dylib` -- make sure to specify the installation prefix when\nyou compile: `make PREFIX=\u002Fusr`). Make sure to run `make test` to verify\nthat your build produces valid results. `sudo make install PREFIX=\u002Fusr`\ninstalls it to your system.\n\n### Command-line utility\n\n`argon2` is a command-line utility to test specific Argon2 instances\non your system. To show usage instructions, run\n`.\u002Fargon2 -h` as\n```\nUsage:  .\u002Fargon2 [-h] salt [-i|-d|-id] [-t iterations] [-m memory] [-p parallelism] [-l hash length] [-e|-r] [-v (10|13)]\n        Password is read from stdin\nParameters:\n        salt            The salt to use, at least 8 characters\n        -i              Use Argon2i (this is the default)\n        -d              Use Argon2d instead of Argon2i\n        -id             Use Argon2id instead of Argon2i\n        -t N            Sets the number of iterations to N (default = 3)\n        -m N            Sets the memory usage of 2^N KiB (default 12)\n        -p N            Sets parallelism to N threads (default 1)\n        -l N            Sets hash output length to N bytes (default 32)\n        -e              Output only encoded hash\n        -r              Output only the raw bytes of the hash\n        -v (10|13)      Argon2 version (defaults to the most recent version, currently 13)\n        -h              Print argon2 usage\n```\nFor example, to hash \"password\" using \"somesalt\" as a salt and doing 2\niterations, consuming 64 MiB, using four parallel threads and an output hash\nof 24 bytes\n```\n$ echo -n \"password\" | .\u002Fargon2 somesalt -t 2 -m 16 -p 4 -l 24\nType:           Argon2i\nIterations:     2\nMemory:         65536 KiB\nParallelism:    4\nHash:           45d7ac72e76f242b20b77b9bf9bf9d5915894e669a24e6c6\nEncoded:        $argon2i$v=19$m=65536,t=2,p=4$c29tZXNhbHQ$RdescudvJCsgt3ub+b+dWRWJTmaaJObG\n0.188 seconds\nVerification ok\n```\n\n### Library\n\n`libargon2` provides an API to both low-level and high-level functions\nfor using Argon2.\n\nThe example program below hashes the string \"password\" with Argon2i\nusing the high-level API and then using the low-level API. While the\nhigh-level API takes the three cost parameters (time, memory, and\nparallelism), the password input buffer, the salt input buffer, and the\noutput buffers, the low-level API takes in these and additional parameters\n, as defined in [`include\u002Fargon2.h`](include\u002Fargon2.h).\n\nThere are many additional parameters, but we will highlight three of them here.\n\n1. The `secret` parameter, which is used for [keyed hashing](\n   https:\u002F\u002Fen.wikipedia.org\u002Fwiki\u002FHash-based_message_authentication_code).\n   This allows a secret key to be input at hashing time (from some external\n   location) and be folded into the value of the hash. This means that even if\n   your salts and hashes are compromised, an attacker cannot brute-force to find\n   the password without the key.\n\n2. The `ad` parameter, which is used to fold any additional data into the hash\n   value. Functionally, this behaves almost exactly like the `secret` or `salt`\n   parameters; the `ad` parameter is folding into the value of the hash.\n   However, this parameter is used for different data. The `salt` should be a\n   random string stored alongside your password. The `secret` should be a random\n   key only usable at hashing time. The `ad` is for any other data.\n\n3. The `flags` parameter, which determines which memory should be securely\n   erased. This is useful if you want to securely delete the `pwd` or `secret`\n   fields right after they are used. To do this set `flags` to either\n   `ARGON2_FLAG_CLEAR_PASSWORD` or `ARGON2_FLAG_CLEAR_SECRET`. To change how\n   internal memory is cleared, change the global flag\n   `FLAG_clear_internal_memory` (defaults to clearing internal memory).\n\nHere the time cost `t_cost` is set to 2 iterations, the\nmemory cost `m_cost` is set to 2\u003Csup>16\u003C\u002Fsup> kibibytes (64 mebibytes),\nand parallelism is set to 1 (single-thread).\n\nCompile for example as `gcc test.c libargon2.a -Isrc -o test`, if the program\nbelow is named `test.c` and placed in the project's root directory.\n\n```c\n#include \"argon2.h\"\n#include \u003Cstdio.h>\n#include \u003Cstring.h>\n#include \u003Cstdlib.h>\n\n#define HASHLEN 32\n#define SALTLEN 16\n#define PWD \"password\"\n\nint main(void)\n{\n    uint8_t hash1[HASHLEN];\n    uint8_t hash2[HASHLEN];\n\n    uint8_t salt[SALTLEN];\n    memset( salt, 0x00, SALTLEN );\n\n    uint8_t *pwd = (uint8_t *)strdup(PWD);\n    uint32_t pwdlen = strlen((char *)pwd);\n\n    uint32_t t_cost = 2;            \u002F\u002F 2-pass computation\n    uint32_t m_cost = (1\u003C\u003C16);      \u002F\u002F 64 mebibytes memory usage\n    uint32_t parallelism = 1;       \u002F\u002F number of threads and lanes\n\n    \u002F\u002F high-level API\n    argon2i_hash_raw(t_cost, m_cost, parallelism, pwd, pwdlen, salt, SALTLEN, hash1, HASHLEN);\n\n    \u002F\u002F low-level API\n    argon2_context context = {\n        hash2,  \u002F* output array, at least HASHLEN in size *\u002F\n        HASHLEN, \u002F* digest length *\u002F\n        pwd, \u002F* password array *\u002F\n        pwdlen, \u002F* password length *\u002F\n        salt,  \u002F* salt array *\u002F\n        SALTLEN, \u002F* salt length *\u002F\n        NULL, 0, \u002F* optional secret data *\u002F\n        NULL, 0, \u002F* optional associated data *\u002F\n        t_cost, m_cost, parallelism, parallelism,\n        ARGON2_VERSION_13, \u002F* algorithm version *\u002F\n        NULL, NULL, \u002F* custom memory allocation \u002F deallocation functions *\u002F\n        \u002F* by default only internal memory is cleared (pwd is not wiped) *\u002F\n        ARGON2_DEFAULT_FLAGS\n    };\n\n    int rc = argon2i_ctx( &context );\n    if(ARGON2_OK != rc) {\n        printf(\"Error: %s\\n\", argon2_error_message(rc));\n        exit(1);\n    }\n    free(pwd);\n\n    for( int i=0; i\u003CHASHLEN; ++i ) printf( \"%02x\", hash1[i] ); printf( \"\\n\" );\n    if (memcmp(hash1, hash2, HASHLEN)) {\n        for( int i=0; i\u003CHASHLEN; ++i ) {\n            printf( \"%02x\", hash2[i] );\n        }\n        printf(\"\\nfail\\n\");\n    }\n    else printf(\"ok\\n\");\n    return 0;\n}\n```\n\nTo use Argon2d instead of Argon2i call `argon2d_hash_raw` instead of\n`argon2i_hash_raw` using the high-level API, and `argon2d` instead of\n`argon2i` using the low-level API. Similarly for Argon2id, call `argon2id_hash_raw`\nand `argon2id`.\n\nTo produce the crypt-like encoding rather than the raw hash, call\n`argon2i_hash_encoded` for Argon2i, `argon2d_hash_encoded` for Argon2d, and\n`argon2id_hash_encoded` for Argon2id\n\nSee [`include\u002Fargon2.h`](include\u002Fargon2.h) for API details.\n\n*Note: in this example the salt is set to the all-`0x00` string for the\nsake of simplicity, but in your application you should use a random salt.*\n\n\n### Benchmarks\n\n`make bench` creates the executable `bench`, which measures the execution\ntime of various Argon2 instances:\n\n```\n$ .\u002Fbench\nArgon2d 1 iterations  1 MiB 1 threads:  5.91 cpb 5.91 Mcycles\nArgon2i 1 iterations  1 MiB 1 threads:  4.64 cpb 4.64 Mcycles\n0.0041 seconds\n\nArgon2d 1 iterations  1 MiB 2 threads:  2.76 cpb 2.76 Mcycles\nArgon2i 1 iterations  1 MiB 2 threads:  2.87 cpb 2.87 Mcycles\n0.0038 seconds\n\nArgon2d 1 iterations  1 MiB 4 threads:  3.25 cpb 3.25 Mcycles\nArgon2i 1 iterations  1 MiB 4 threads:  3.57 cpb 3.57 Mcycles\n0.0048 seconds\n\n(...)\n\nArgon2d 1 iterations  4096 MiB 2 threads:  2.15 cpb 8788.08 Mcycles\nArgon2i 1 iterations  4096 MiB 2 threads:  2.15 cpb 8821.59 Mcycles\n13.0112 seconds\n\nArgon2d 1 iterations  4096 MiB 4 threads:  1.79 cpb 7343.72 Mcycles\nArgon2i 1 iterations  4096 MiB 4 threads:  2.72 cpb 11124.86 Mcycles\n19.3974 seconds\n\n(...)\n```\n\n## Bindings\n\nBindings are available for the following languages (make sure to read\ntheir documentation):\n\n* [Android (Java\u002FKotlin)](https:\u002F\u002Fgithub.com\u002Flambdapioneer\u002Fargon2kt) by [@lambdapioneer](https:\u002F\u002Fgithub.com\u002Flambdapioneer)\n* [Dart](https:\u002F\u002Fgithub.com\u002Ftmthecoder\u002Fdargon2) by [@tmthecoder](https:\u002F\u002Fgithub.com\u002Ftmthecoder)\n* [Elixir](https:\u002F\u002Fgithub.com\u002Friverrun\u002Fargon2_elixir) by [@riverrun](https:\u002F\u002Fgithub.com\u002Friverrun)\n* [Erlang](https:\u002F\u002Fgithub.com\u002Fergenius\u002Feargon2) by [@ergenius](https:\u002F\u002Fgithub.com\u002Fergenius)\n* [Go](https:\u002F\u002Fgithub.com\u002Ftvdburgt\u002Fgo-argon2) by [@tvdburgt](https:\u002F\u002Fgithub.com\u002Ftvdburgt)\n* [Haskell](https:\u002F\u002Fhackage.haskell.org\u002Fpackage\u002Fargon2) by [@hvr](https:\u002F\u002Fgithub.com\u002Fhvr)\n* [JavaScript (native)](https:\u002F\u002Fgithub.com\u002Franisalt\u002Fnode-argon2), by [@ranisalt](https:\u002F\u002Fgithub.com\u002Franisalt)\n* [JavaScript (native)](https:\u002F\u002Fgithub.com\u002Fjdconley\u002Fargon2themax), by [@jdconley](https:\u002F\u002Fgithub.com\u002Fjdconley)\n* [JavaScript (ffi)](https:\u002F\u002Fgithub.com\u002Fcjlarose\u002Fargon2-ffi), by [@cjlarose](https:\u002F\u002Fgithub.com\u002Fcjlarose)\n* [JavaScript (browser)](https:\u002F\u002Fgithub.com\u002Fantelle\u002Fargon2-browser), by [@antelle](https:\u002F\u002Fgithub.com\u002Fantelle)\n* [JVM](https:\u002F\u002Fgithub.com\u002Fphxql\u002Fargon2-jvm) by [@phXql](https:\u002F\u002Fgithub.com\u002Fphxql)\n* [JVM (with keyed hashing)](https:\u002F\u002Fgithub.com\u002Fkosprov\u002Fjargon2-api) by [@kosprov](https:\u002F\u002Fgithub.com\u002Fkosprov)\n* [Lua (native)](https:\u002F\u002Fgithub.com\u002FthibaultCha\u002Flua-argon2) by [@thibaultCha](https:\u002F\u002Fgithub.com\u002FthibaultCha)\n* [Lua (ffi)](https:\u002F\u002Fgithub.com\u002FthibaultCha\u002Flua-argon2-ffi) by [@thibaultCha](https:\u002F\u002Fgithub.com\u002FthibaultCha)\n* [OCaml](https:\u002F\u002Fgithub.com\u002FKhady\u002Focaml-argon2) by [@Khady](https:\u002F\u002Fgithub.com\u002FKhady)\n* [Python (native)](https:\u002F\u002Fpypi.python.org\u002Fpypi\u002Fargon2), by [@flamewow](https:\u002F\u002Fgithub.com\u002Fflamewow)\n* [Python (ffi)](https:\u002F\u002Fpypi.python.org\u002Fpypi\u002Fargon2_cffi), by [@hynek](https:\u002F\u002Fgithub.com\u002Fhynek)\n* [Python (ffi, with keyed hashing)](https:\u002F\u002Fgithub.com\u002Fthusoy\u002Fporridge), by [@thusoy](https:\u002F\u002Fgithub.com\u002Fthusoy)\n* [Python (ffi, with keyed hashing)](https:\u002F\u002Fgithub.com\u002Fultrahorizon\u002Fpyargon2), by [@ultrahorizon](https:\u002F\u002Fgithub.com\u002Fultrahorizon)\n* [R](https:\u002F\u002Fcran.r-project.org\u002Fpackage=argon2) by [@wrathematics](https:\u002F\u002Fgithub.com\u002Fwrathematics)\n* [Ruby](https:\u002F\u002Fgithub.com\u002Ftechnion\u002Fruby-argon2) by [@technion](https:\u002F\u002Fgithub.com\u002Ftechnion)\n* [Rust](https:\u002F\u002Fgithub.com\u002Fquininer\u002Fargon2-rs) by [@quininer](https:\u002F\u002Fgithub.com\u002Fquininer)\n* [Rust](https:\u002F\u002Fdocs.rs\u002Fargonautica\u002F) by [@bcmyers](https:\u002F\u002Fgithub.com\u002Fbcmyers\u002F)\n* [C#\u002F.NET CoreCLR](https:\u002F\u002Fgithub.com\u002Fkmaragon\u002FKonscious.Security.Cryptography) by [@kmaragon](https:\u002F\u002Fgithub.com\u002Fkmaragon)\n* [Perl](https:\u002F\u002Fgithub.com\u002FLeont\u002Fcrypt-argon2) by [@leont](https:\u002F\u002Fgithub.com\u002FLeont)\n* [mruby](https:\u002F\u002Fgithub.com\u002FAsmod4n\u002Fmruby-argon2) by [@Asmod4n](https:\u002F\u002Fgithub.com\u002FAsmod4n)\n* [Swift](https:\u002F\u002Fgithub.com\u002FImKcat\u002FCatCrypto) by [@ImKcat](https:\u002F\u002Fgithub.com\u002FImKcat)\n* [Swift](https:\u002F\u002Fgithub.com\u002Ftmthecoder\u002FArgon2Swift) by [@tmthecoder](https:\u002F\u002Fgithub.com\u002Ftmthecoder)\n\n\n## Test suite\n\nThere are two sets of test suites. One is a low level test for the hash\nfunction, the other tests the higher level API. Both of these are built and\nexecuted by running:\n\n`make test`\n\n## Intellectual property\n\nExcept for the components listed below, the Argon2 code in this\nrepository is copyright (c) 2015 Daniel Dinu, Dmitry Khovratovich (main\nauthors), Jean-Philippe Aumasson and Samuel Neves, and dual licensed under the\n[CC0 License](https:\u002F\u002Fcreativecommons.org\u002Fabout\u002Fcc0) and the\n[Apache 2.0 License](https:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0). For more info\nsee the LICENSE file.\n\nThe string encoding routines in [`src\u002Fencoding.c`](src\u002Fencoding.c) are\ncopyright (c) 2015 Thomas Pornin, and under\n[CC0 License](https:\u002F\u002Fcreativecommons.org\u002Fabout\u002Fcc0).\n\nThe BLAKE2 code in [`src\u002Fblake2\u002F`](src\u002Fblake2) is copyright (c) Samuel\nNeves, 2013-2015, and under\n[CC0 License](https:\u002F\u002Fcreativecommons.org\u002Fabout\u002Fcc0).\n\nAll licenses are therefore GPL-compatible.\n","Argon2 是一种密码哈希函数，赢得了密码哈希竞赛（PHC）。其核心功能包括高效利用内存和多计算单元，以抵御时间和空间的权衡攻击。技术特点上，Argon2 提供了三种变体：Argon2i、Argon2d 和 Argon2id，分别适用于不同安全需求场景。其中，Argon2i 适合需要防止侧信道时序攻击的密码存储和密钥导出应用；Argon2d 则更适合于无需担心侧信道攻击的应用如加密货币；而 Argon2id 结合了前两者的优势，既具有一定的抗时序攻击能力，又能有效防御 GPU 破解攻击。该算法通过时间成本、内存成本和平行度三个参数进行配置，允许用户根据具体需求调整性能与安全性之间的平衡。项目提供了 C 语言实现版本，并支持多种操作系统平台上的编译安装及使用。","2026-06-11 03:07:32","top_language"]