You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: concepts/secrets/about.md
+7-11Lines changed: 7 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,45 +7,41 @@ The [`secrets`][secrets] module overlaps with `random` in some of its functional
7
7
-`random` is optimized for high performance in modelling and simulation, with "good enough" pseudo-random number generation.
8
8
-`secrets` is designed to be crytographically secure for applications such as password hashing, security token generation, and account authentication.
9
9
10
-
11
10
Further details on why the addition of the `secrets` module proved necessary are given in [PEP 506][PEP506].
12
11
13
-
The `secrets` is relatively small and straightforward, with methods for generating random integers, bits, bytes or tokens, or a random entry from a given sequence.
14
-
15
-
To use `scerets`, you mush first `import` it:
12
+
The `secrets` module is relatively small and straightforward, with methods for generating random integers, bits, bytes, tokens, or a random entry from a given sequence.
16
13
14
+
To use `secrets`, you must first `import` it:
17
15
18
16
```python
19
17
>>>import secrets
20
18
21
-
#Returns n, where 0 <= n < 1000.
19
+
#Returns n, where 0 <= n < 1000.
22
20
>>> secrets.randbelow(1000)
23
21
577
24
22
25
-
#32-bit integers.
23
+
#32-bit integers.
26
24
>>> secrets.randbits(32)
27
25
3028709440
28
26
29
27
>>>bin(secrets.randbits(32))
30
28
'0b11111000101100101111110011110100'
31
29
32
-
#Pick at random from a sequence.
30
+
#Pick at random from a sequence.
33
31
>>> secrets.choice(['my', 'secret', 'thing'])
34
32
'thing'
35
33
36
-
#Generate a token made up of random hexadecimal digits.
34
+
#Generate a token made up of random hexadecimal digits.
#Generate a URL-safe token of random alphanumeric characters.
38
+
#Generate a URL-safe token of random alphanumeric characters.
41
39
>>> secrets.token_urlsafe(16)
42
40
'gkSUKRdiPDHqmImPi2HMnw'
43
41
```
44
42
45
-
46
43
If you are writing security-sensitive applications, you will certainly want to read the [full documentation][secrets], which gives further advice and examples.
Copy file name to clipboardExpand all lines: concepts/secrets/introduction.md
-1Lines changed: 0 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,6 @@ The [`secrets`][secrets] module overlaps with `random` in some of its functional
7
7
-`random` is optimized for high performance in modelling and simulation, with "good enough" pseudo-random number generation.
8
8
-`secrets` is designed to be crytographically secure for applications such as password hashing, security token generation, and account authentication.
9
9
10
-
11
10
Further details on why the addition of the `secrets` module proved necessary are given in [PEP 506][PEP506].
12
11
13
12
If you are writing security-sensitive applications, you will certainly want to read the [full documentation][secrets], which gives further advice and examples.
"blurb": "There are four main string formatting methods. A '%' formatting mini-language is supported, but is considered outdated. String interpolation (f-strings) and 'str.format()'are newer, and can be used for complex or conditional substitution. 'string.template()' substitution is used for internationalization, where f-strings will not translate.",
2
+
"blurb": "There are four main string formatting methods. A '%' formatting mini-language is supported, but is considered outdated. String interpolation (f-strings) and 'str.format()'are newer, and can be used for complex or conditional substitution. 'string.Template()' substitution is used for internationalization, where f-strings will not translate.",
0 commit comments