Skip to content

Commit c5ed6c5

Browse files
authored
Merge pull request pallets#4301 from kkirsche/secret_key_via_secrets
use secrets module for SECRET_KEY generation in docs
2 parents 8ddf80c + 58a08a1 commit c5ed6c5

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

docs/config.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ method::
3838

3939
app.config.update(
4040
TESTING=True,
41-
SECRET_KEY=b'_5#y2L"F4Q8z\n\xec]/'
41+
SECRET_KEY='192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'
4242
)
4343

4444

@@ -180,8 +180,8 @@ The following configuration values are used internally by Flask:
180180
application. It should be a long random ``bytes`` or ``str``. For
181181
example, copy the output of this to your config::
182182

183-
$ python -c 'import os; print(os.urandom(16))'
184-
b'_5#y2L"F4Q8z\n\xec]/'
183+
$ python -c 'import secrets; print(secrets.token_hex()))'
184+
'192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'
185185

186186
**Do not reveal the secret key when posting questions or committing code.**
187187

@@ -468,7 +468,7 @@ sure to use uppercase letters for your config keys.
468468
Here is an example of a configuration file::
469469

470470
# Example configuration
471-
SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/'
471+
SECRET_KEY = '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'
472472

473473
Make sure to load the configuration very early on, so that extensions have
474474
the ability to access the configuration when starting up. There are other

docs/quickstart.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -847,8 +847,8 @@ sessions work::
847847
generator. Use the following command to quickly generate a value for
848848
:attr:`Flask.secret_key` (or :data:`SECRET_KEY`)::
849849

850-
$ python -c 'import os; print(os.urandom(16))'
851-
b'_5#y2L"F4Q8z\n\xec]/'
850+
$ python -c 'import secrets; print(secrets.token_hex())'
851+
'192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'
852852

853853
A note on cookie-based sessions: Flask will take the values you put into the
854854
session object and serialize them into a cookie. If you are finding some

docs/tutorial/deploy.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,17 @@ You can use the following command to output a random secret key:
8888

8989
.. code-block:: none
9090
91-
$ python -c 'import os; print(os.urandom(16))'
91+
$ python -c 'import secrets; print(secrets.token_hex())'
9292
93-
b'_5#y2L"F4Q8z\n\xec]/'
93+
'192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'
9494
9595
Create the ``config.py`` file in the instance folder, which the factory
9696
will read from if it exists. Copy the generated value into it.
9797

9898
.. code-block:: python
9999
:caption: ``venv/var/flaskr-instance/config.py``
100100
101-
SECRET_KEY = b'_5#y2L"F4Q8z\n\xec]/'
101+
SECRET_KEY = '192b9bdd22ab9ed4d12e236c78afcb9a393ec15f71bbf5dc987d54727823bcbf'
102102
103103
You can also set any other necessary configuration here, although
104104
``SECRET_KEY`` is the only one needed for Flaskr.

0 commit comments

Comments
 (0)