{"id":13622878,"url":"https://github.com/timoh6/GenPhrase","last_synced_at":"2025-04-15T10:31:45.123Z","repository":{"id":4062483,"uuid":"5166226","full_name":"timoh6/GenPhrase","owner":"timoh6","description":"GenPhrase is a secure passphrase generator for PHP applications.","archived":false,"fork":false,"pushed_at":"2025-02-17T10:07:25.000Z","size":121,"stargazers_count":116,"open_issues_count":1,"forks_count":8,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-03-12T22:37:46.499Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/timoh6.png","metadata":{"files":{"readme":"README.markdown","changelog":"CHANGELOG.markdown","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":"2012-07-24T14:02:08.000Z","updated_at":"2025-02-25T07:24:02.000Z","dependencies_parsed_at":"2022-07-29T01:39:00.790Z","dependency_job_id":null,"html_url":"https://github.com/timoh6/GenPhrase","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoh6%2FGenPhrase","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoh6%2FGenPhrase/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoh6%2FGenPhrase/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/timoh6%2FGenPhrase/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/timoh6","download_url":"https://codeload.github.com/timoh6/GenPhrase/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248991709,"owners_count":21194925,"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-08-01T21:01:25.274Z","updated_at":"2025-04-15T10:31:45.117Z","avatar_url":"https://github.com/timoh6.png","language":"PHP","readme":"About\n=====\n\n[![Packagist](https://img.shields.io/packagist/v/genphrase/genphrase.svg)](https://packagist.org/packages/genphrase/genphrase)\n[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](LICENSE)\n[![Build Status](https://secure.travis-ci.org/timoh6/GenPhrase.png)](http://travis-ci.org/timoh6/GenPhrase)\n\n\u003e [!NOTE]\n\u003e Sadly, GenPhrase hasn't had any updates in quite a long while. Future development\nand maintenance of GenPhrase will be at [Drenso/GenPhrase](https://github.com/Drenso/GenPhrase)\n\nGenPhrase is a secure passphrase generator for PHP applications. GenPhrase is\nbased on passwdqc's pwqgen program. See http://www.openwall.com/passwdqc/\n\nGenPhrase can be used to generate secure and easy to memorize random\npassphrases. For example output, see [examples](#what-kind-of-passphrases-genphrase-generate).\n\nGenPhrase can use arbitrary size wordlists. Words for a passphrase are selected\nuniformly at random from the wordset.\n\nGenPhrase has a series of small security bug bounties. For more information, see\n[GenPhrase Security Bug Bounties](http://timoh6.github.io/2014/08/20/GenPhrase-security-bug-bounties.html).\n\n\nRequirements\n------------\n\nGenPhrase requires PHP version 5.3 or greater with BC Math (--enable-bcmath).\nmbstring extension must be available if words are modified (e.g. capitalized).\n\n__HHVM compatibility__\n\nHipHop VM v2.3 and later is confirmed to support GenPhrase. Earlier versions\nof HHVM may work as well.\n\n\nInstallation\n------------\n\nGenPhrase supports installation using Composer, but make sure you use at least Composer version 1.0.0-beta1\nto install GenPhrase (Composer was vulnerable to MITM attacks before 1.0.0-beta1):\n\n[genphrase/genphrase ](https://packagist.org/packages/genphrase/genphrase)\n\n\nPassphrase generation with GenPhrase\n------------------------------------\n\nBy default, GenPhrase generates passphrases using english words (english.lst).\nThose passphrases will have at least 50 bits of entropy.\n\nGenPhrase has currently two built-in wordlists: english.lst (default) and\ndiceware.lst. You can add/remove/combine wordlists as you like.\n\nMore about the original english wordlist via Openwall:\nhttp://cvsweb.openwall.com/cgi/cvsweb.cgi/Owl/packages/passwdqc/passwdqc/wordset_4k.c?rev=1.5;content-type=text%2Fplain\n\nThe only modification between the GenPhrase english wordlist and the Openwall\nwordlist is we changed all the words to be lowercase.\n\nNote, the Diceware list bundled with GenPhrase as of 1.1.0 is EFF's \"long\" version,\nbut without four words which contains \"-\" character\n(as this character is a GenPhrase separator character). For more information\nabout EFF's Diceware list, see:\nhttps://www.eff.org/deeplinks/2016/07/new-wordlists-random-passphrases\n\nNote, GenPhrase allows you to specify separator characters which may be used between the words.\nIf you want to specify these separator characters, make sure you use only unique single-byte characters.\nMore information about setting separator characters is in the usage examples below.\n\n### What kind of passphrases GenPhrase generate?\n\nA few examples to demonstrate the output:\n\nWith default settings, the passphrase would be for example like:\n\n    Alter Berlin Paint meaning\n\nGenerating a passphrase having 40 bits of entropy:\n\n    musica$Menu\u0026Quota\n\nA passphrase having 50 bits of entropy and separator characters and word\ncapitalizing disabled:\n\n    setthenrolegiftdancing\n\n\nUsage\n-----\n\n``` php\n\u003c?php\nrequire '/path/to/library/GenPhrase/Loader.php';\n$loader = new GenPhrase\\Loader();\n$loader-\u003eregister();\n```\n``` php\n\u003c?php\n$gen = new GenPhrase\\Password();\n\n// Generate a passphrase using english words and (at least) 50 bits of entropy.\n$gen-\u003egenerate();\n\n// Generate a passphrase using english words and custom amount of entropy.\n// Entropy must be between 26.0 and 120.0 bits.\n$gen-\u003egenerate(46);\n\n// Remove the default (english) wordlist. This is because we want to use only\n// the Diceware list. If you add a new wordlist, but you do not remove the\n// default wordlist, then GenPhrase will combine those wordlists.\n$gen-\u003eremoveWordlist('default');\n\n// Add Diceware wordlist.\n// $gen-\u003eaddWordlist('/path/to/GenPhrase/Wordlists/diceware.lst', 'diceware');\n// Or more simply (if you give just a filename, GenPhrase will look this\n// filename from \"Wordlists\" folder automatically):\n$gen-\u003eaddWordlist('diceware.lst', 'diceware');\n// When creating Diceware phrases, it is recommended not to capitalize any\n// words and not to add separator characters (except space, which gets automatically added). To make that\n// happen, we configure GenPhrase a little bit more:\n$gen-\u003edisableSeparators(true); // No separator characters are inserted (except space)\n$gen-\u003edisableWordModifier(true); // No words are capitalized or changed to lower case (words are not modified)\necho $gen-\u003egenerate(65) // This will output six \"word\" passphrases.\n\n// It is possible to force GenPhrase to always use separator characters\n// (whether it \"makes sense\" or not).\n// For example, if you generate a passphrase having 35 bits of entropy,\n// with default settings, you would get something like: \"word1 word2 word3\".\n// If you force the usage of separators, you would get something like:\n// \"word1!word2*word3\".\n$gen-\u003ealwaysUseSeparators(true);\n// For possible use cases, see pull request #1.\n\n// Change the separator characters.\n$gen-\u003esetSeparators('123456789');\n// NOTE: separator characters must be unique single-byte characters.\n// NOTE: you must not use space as a separator character, because space is\n// automatically added when appropriate.\n// NOTE: minimum number of separator characters is 1. If there there is only\n// one unique separator character, it won't add any entropy to the passphrase\n// (passphrase may require extra word and become longer).\n\n// Set character encoding. The encoding is used internally by GenPhrase when\n// calling mb_ functions.\n$gen-\u003esetEncoding('iso-8859-1');\n// By default GenPhrase uses utf-8 encoding.\n```\n\n\nHow is entropy calculated?\n--------------------------\n\nAs long as we have only unique elements in our wordlist and each element is\nequally likely to be chosen, we can calculate the entropy per \"element\"\n(usually a word) as follows:\n`log2(count_of_elements)`\n\nIf we choose, say, 4 elements, the total entropy is:\n`4 * log2(count_of_elements)`\n\nIf we choose 2 elements and one separator element:\n`2 * log2(count_of_elements)` + `log2(count_of_separators)`\n\nBy default, GenPhrase will randomly (50:50 change) modify the first character of\na word to either lower or upper case\n(\"Apple\" becomes \"apple\", \"orange\" becomes \"Orange\" etc.\n\nIn terms of entropy, this means we are actually doubling the \"unique element count\"\n(our wordlist has, say, a word \"apple\", so we could come up with a word \"apple\" or\n\"Apple\"):\n`log2(2 * count_of_elements)`\n\n\nIssues or questions?\n--------------------\n\nMail me at timoh6@gmail.com or use GitHub.\n","funding_links":[],"categories":["目录","Table of Contents","密码 Passwords","PHP","密码( Passwords )"],"sub_categories":["密码 Passwords","Passwords"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoh6%2FGenPhrase","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftimoh6%2FGenPhrase","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftimoh6%2FGenPhrase/lists"}