Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use the secrets module with a version of Python earlier than 3.6?

Python's secrets module was introduced in version 3.6. I'm working on an application using Python 3.4. Is there a way I can import the secrets module in a 3.4 environment (a la from __future__ import print)?

If not, is there a 3rd party module with comparable functionality?

like image 794
Stew Avatar asked Apr 09 '18 20:04

Stew


People also ask

How does Python secrets module work?

The secrets module is used for generating cryptographically strong random numbers suitable for managing data such as passwords, account authentication, security tokens, and related secrets.

How do you use secret in Python?

Creating Secrets A secret contains one or more secret versions. They can be created using the gcloud command-line, but they can also be created using Python. In order to use a secret, you first need to create the secret with the name of the secret, then you add a version of the secret, being the value of the secret.

What is the Python version?

Python 3.11. 0, documentation released on 24 October 2022. Python 3.10. 7, documentation released on 6 September 2022.


1 Answers

A backport of the secrets module for Python versions 2.7, 3.4 and 3.5 now exists: the (somewhat confusingly named) python2-secrets.

Installation:

pip install python2-secrets
like image 139
Zero Piraeus Avatar answered Oct 04 '22 21:10

Zero Piraeus