GithubHelp home page GithubHelp logo

robdwaller / wordpress-salts-generator Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 6.0 29 KB

A key and salts generator for WordPress that works with both wp-config and .env files.

License: MIT License

PHP 100.00%
wordpress keys salts cli composer composer-package

wordpress-salts-generator's Introduction

WordPress Salts Generator

A key and salts generator for WordPress that works with both wp-config and .env files.

  • This library is for use with a composer setup of WordPress.
  • Keys and salts are generated via the command line.

Installation

To install this library either use the composer require command.

composer require rbdwllr/wordpress-salts-generator 0.1.*

Or add it straight to your composer.json file and run composer update.

require: {
    "rbdwllr/wordpress-salts-generator": "0.1.*"
}

Commands

Their are two simple commands available for generating the keys and salts.

// Generates traditional WordPress 'define' keys and salts.
vendor/bin/wpsalts traditional

// Generates keys and salts that can be used in a .env file.
vendor/bin/wpsalts dotenv

If you don't add a command the vendor/bin/wpsalts command it will output the traditional WordPress salts and keys.

Append to File

If you would like to append the keys directly to the end of an .env file you can use the --clean flag as follows.

vendor/bin/wpsalts dotenv --clean >> .env

The clean flag removes any messaging and formatting around the output, and the >> operator appends the output to the end of the .env file on a new line.

Output Examples

Traditional WordPress

Copy and paste these keys and salts into your wp-config.php file.

define('AUTH_KEY', 'dva\uhm"cDc<$U5E> )euW<UzK{ WQ7tt;j:paBPyY16<&f;b|n]|pj9%|=xRA;'');
define('SECURE_AUTH_KEY', 'Q)hZ.Hp]meJI.X-:s+Cp2o4:wafkbxO}mfyp??e">bqHRC)|o(sB)9G-n4O2VJ;!');
define('LOGGED_IN_KEY', 'kOq )c"=0>E} c;?PwD;lt0(N9N>%,#OS"]3>,!@[&]]i>G90ucaBxz2\hh]}I@Z');
define('NONCE_KEY', 't>ZZepdu/(8>4|3k5covc7R'":*rhyY>{eZjK4HB:@i5l/d8XTTc(P.v(H|Q/mg4');
define('AUTH_SALT', '{B>CWa$zjM+KN(,(-4yD(pFfdeF 07mPp1xOMkL bDm!X>}p){~(J4\~-AO+0-ZV');
define('SECURE_AUTH_SALT', 'lr'_2T^{O/<LK v<:fa^Sw-i]5\t yt.:I#?kSa(l 8A7H%/!E(c1dzX(r[}3YpB');
define('LOGGED_IN_SALT', '%^]P]dVVJ"Pgd[tW-.}mMvx..yRW+99E7yCVb:PYA-k1[2W0LHM^fG'XtPsuGF"y');
define('NONCE_SALT', ' 6quTRjx9eQ"6:$QrV]!q"8%38#NGh>ODwU:tw8&nU^Ci}_[`ItiWK]e|n t<f /');

DotEnv

Copy and paste these keys and salts into your .env file.

AUTH_KEY = 'EXOxcC~nqA{m{B?pw$$G^kIll&j@7K~\+rGaD!84>J^C2H.w"U\Ut<55\&W[ IdS'
SECURE_AUTH_KEY = 'z =Q9?I),/%7`E0jEM(#5VV'S NdLFYL<e2-jSyQoV*Jzxbs3`oIs;pZHcEH"2L&'
LOGGED_IN_KEY = 'H #u*_!('^[s>=4?$.s3?yo9KJk8Lv-Dn O6,ZCE>aFh-5KaXbBzV9#^t9rJuTgt'
NONCE_KEY = 'bdt.I)jh6Nz/e,|S-QepePTSd@93E$vk%oX1yd"A,DNExX+v&;>2>^Ni$G%l&YC9'
AUTH_SALT = '$81GB@i@ 0qW@~<<M$j`>yxQ )Q56PyJ6ukOnH]@_:}x-/BAm-Io]=CyJU^T(|7%'
SECURE_AUTH_SALT = '/k4O1L)q@7wJ^~;b`"U6X9s,~7iRAc8v-ypMOM|X.yN=0"gVh|x~$V +Mw(eZ33T'
LOGGED_IN_SALT = '_o_jpvW#iq}l-'Kc&vU}Tht\w,-:462z8=;!x3 =1NyD&[>k^EAZjm(F#=X+T(G''
NONCE_SALT = '.e1j7;9aWlqoBRdLEe?Vh9{m8V7:<PlAFa@,,(2o5En)^%x*[i\6sq[=*b#+-A0='

Author

Rob Waller @RobDWaller

wordpress-salts-generator's People

Contributors

robdwaller avatar tylerwiegand avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

wordpress-salts-generator's Issues

Dotenv values containing spaces must be surrounded by quotes.

PHP Fatal error:  Uncaught Dotenv\Exception\InvalidFileException: Dotenv values containing spaces must be surrounded by quotes. in /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php:76

Anytime I install wp via command line (as I usually do) it doesn't like the spaces in these generated salts. Using the "official" doesn't present this issue, as they don't seem to include spaces in the salts.

Example -- these salts:

AUTH_KEY = '?+$N\p:bAXBN!2n`xdJvGa3O//S]*9!rA}BoDI1V&Qo8vfBy3!iTB;J-YYcaS*rW'
SECURE_AUTH_KEY = 'w@HyRw:$rAZ2"ePbIT5(N*oEfAOQu(IlndGY0QNA=Z^>k9H,G5d^$IY,cc.P_h\N'
LOGGED_IN_KEY = '<UA2E5O !OM9,[_4!x4G6@Ee(N'^2$UXRi9y!rff\9ir>=X:1c]5k/hFoAFE>h&4'
NONCE_KEY = ']Vuo"N,gWdo0z(:I sny!Gw;BK00tof9M$u2Fl41dIJ&},wja'Jt*MC%ef]]SyL@'
AUTH_SALT = 'Q$$I9dvY4&!|?(oWKW<8b+iWb\mD>1_Llx/&Kdy_\dab_\,PtSg9"rM[KfTOIZtb'
SECURE_AUTH_SALT = 'rLu,71kGUiiq-(S^f0F=;5,t< f9l*-%s*.4gt?gKLNcm)q2!%TR#jP=b[Vhld0O'
LOGGED_IN_SALT = 'F)Ud&*/*&Kd8;L~`Sx 55fugy@CmsnaaBZRAe7T0e!W1hJlUB&|qDJIJefU2t2I!'
NONCE_SALT = 'Omz/e3LGhT)T_).xPeg*)=xh?5|2"<0u=$5,75%HIH!4rTY25UH}.j12aBn?@L*x'

produce this output:

PHP Fatal error:  Uncaught Dotenv\Exception\InvalidFileException: Dotenv values containing spaces must be surrounded by quotes. in /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php:76
Stack trace:
#0 [internal function]: Dotenv\Parser::Dotenv\{closure}(Array, '!')
#1 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php(84): array_reduce(Array, Object(Closure), Array)
#2 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(237): Dotenv\Parser::parseValue(''<UA2E5O !OM9,[...')
#3 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(151): Dotenv\Loader->sanitiseVariableValue('LOGGED_IN_KEY', ''<UA2E5O !OM9,[...')
#4 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(128): Dotenv\Loader->processFilters('LOGGED_IN_KEY', ''<UA2E5O !OM9,[...')
#5 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(323): Dotenv\Loader->normaliseEnvironmentVariable('LOGGED_IN_KEY = in /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php on line 76

Fatal error: Uncaught Dotenv\Exception\InvalidFileException: Dotenv values containing spaces must be surrounded by quotes. in /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php:76
Stack trace:
#0 [internal function]: Dotenv\Parser::Dotenv\{closure}(Array, '!')
#1 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php(84): array_reduce(Array, Object(Closure), Array)
#2 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(237): Dotenv\Parser::parseValue(''<UA2E5O !OM9,[...')
#3 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(151): Dotenv\Loader->sanitiseVariableValue('LOGGED_IN_KEY', ''<UA2E5O !OM9,[...')
#4 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(128): Dotenv\Loader->processFilters('LOGGED_IN_KEY', ''<UA2E5O !OM9,[...')
#5 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(323): Dotenv\Loader->normaliseEnvironmentVariable('LOGGED_IN_KEY = in /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php on line 76

and as you can see the "LOGGED_IN_KEY" has a space and then an !

If I surround every like with double quotes, I get this output, and I'm not sure why:

PHP Fatal error:  Uncaught Dotenv\Exception\InvalidFileException: Dotenv values containing spaces must be surrounded by quotes. in /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php:76
Stack trace:
#0 [internal function]: Dotenv\Parser::Dotenv\{closure}(Array, 'e')
#1 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php(84): array_reduce(Array, Object(Closure), Array)
#2 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(237): Dotenv\Parser::parseValue('"w@HyRw:$rAZ2"e...')
#3 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(151): Dotenv\Loader->sanitiseVariableValue('SECURE_AUTH_KEY', '"w@HyRw:$rAZ2"e...')
#4 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(128): Dotenv\Loader->processFilters('SECURE_AUTH_KEY', '"w@HyRw:$rAZ2"e...')
#5 /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Loader.php(323): Dotenv\Loader->normaliseEnvironmentVariable('SECURE_AUTH in /Users/me/sites/client/vendor/vlucas/phpdotenv/src/Parser.php on line 76

If I switch to the "official" salts, this problem goes away entirely. This library used to work for me, so I can only imagine an update to the Dotenv library has produced this issue.

Thank you! Looking forward to a "fix."

Dotenv failed to parse salts due to unexpected whitespace

I'm adding in the salts generated with this package at the end of the composer install run. Only Dotenv can't parse it because of unexpected whitespace. This goes for each line.

Example (generated):
AUTH_KEY = 'K0AtL0ItoIg^jdx615zr]T]#$uUBCu\$~QbeF0'nliC>MFxFQ#IrLr|~:Xpf1wyy'

Example (expected):
AUTH_KEY='K0AtL0ItoIg^jdx615zr]T]#$uUBCu\$~QbeF0'nliC>MFxFQ#IrLr|~:Xpf1wyy'

Salt generator sometimes includes single quote in salt

The salt generator sometimes includes a single quote (') in salt. This results in invalid syntax.

/tmp/foo  $ vendor/bin/wpsalts 
Copy and paste these keys and salts into your wp-config.php file.

define('AUTH_KEY', '6\J72UDkd<rt1!*s~gyNhd(I>%hu%/^SUe6EQ!0H-~*Hn5Wg(EWa$19?IOqDrG`t');
define('SECURE_AUTH_KEY', 'wPaAt1IZUJOp<>,5'#bJ7L@LN|VjEL_X=cV%@},WC\7>Pw{&`wbs0~#z(@q*P7;J');
define('LOGGED_IN_KEY', 'Z;@ewbsi3 Nfj|6ETnVgV:@d`&ek|!LnT6u Sr=7%n#7)y:jtiQlS"-mF/J]7pkb');
define('NONCE_KEY', '{qx?ct\n-t>*mN%QpSu2em.qP-[E3QkGnu~vnH89{Q.O<VLB.wNf.PYMdT(2P4U-');
define('AUTH_SALT', 'Jd_@tpP lw=E,3/tV_0GWM=`q4?QFUJfKW~c4Des)v]+YQAl<A#-G8CX}4i}1c4\');
define('SECURE_AUTH_SALT', 'y|GBR&i+qq7Ih1X["h=a8#=Y\t?]2fB$'uw|"p{@~1TU-X;xnsa(n9-|_P+kZMFD');
define('LOGGED_IN_SALT', 'sM>O}O]*]qe4[*0m}v"2z,dApmqHR%%3hph|Sv0;t7fBi^)P4\Gt[V/tk54gUsn\');
define('NONCE_SALT', '5HK9Tbv)h15pVx_P%a;H]n@;lG?CP.*5/\4B0>i5>4A29K(2d+naExFQxg5f<|OU');

In the above :

<?php
define('SECURE_AUTH_KEY', 'wPaAt1IZUJOp<>,5'#bJ7L@LN|VjEL_X=cV%@},WC\7>Pw{&`wbs0~#z(@q*P7;J');

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.