Skip to content

Commit a0becd6

Browse files
authored
Many fixes and improvements to concept docs (#4220)
1 parent 91fba73 commit a0becd6

6 files changed

Lines changed: 112 additions & 99 deletions

File tree

concepts/secrets/.meta/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"blurb": "The secrets module is a cryptographically-secure alternative to the random module, intended for security-critical uses.",
33
"authors": ["BethanyG", "colinleach"],
4-
"contributors": []
4+
"contributors": ["yrahcaz7"]
55
}

concepts/secrets/about.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,45 +7,41 @@ The [`secrets`][secrets] module overlaps with `random` in some of its functional
77
- `random` is optimized for high performance in modelling and simulation, with "good enough" pseudo-random number generation.
88
- `secrets` is designed to be crytographically secure for applications such as password hashing, security token generation, and account authentication.
99

10-
1110
Further details on why the addition of the `secrets` module proved necessary are given in [PEP 506][PEP506].
1211

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.
1613

14+
To use `secrets`, you must first `import` it:
1715

1816
```python
1917
>>> import secrets
2018

21-
#Returns n, where 0 <= n < 1000.
19+
# Returns n, where 0 <= n < 1000.
2220
>>> secrets.randbelow(1000)
2321
577
2422

25-
#32-bit integers.
23+
# 32-bit integers.
2624
>>> secrets.randbits(32)
2725
3028709440
2826

2927
>>> bin(secrets.randbits(32))
3028
'0b11111000101100101111110011110100'
3129

32-
#Pick at random from a sequence.
30+
# Pick at random from a sequence.
3331
>>> secrets.choice(['my', 'secret', 'thing'])
3432
'thing'
3533

36-
#Generate a token made up of random hexadecimal digits.
34+
# Generate a token made up of random hexadecimal digits.
3735
>>> secrets.token_hex()
3836
'f683d093ea9aa1f2607497c837cf11d7afaefa903c5805f94b64f068e2b9e621'
3937

40-
#Generate a URL-safe token of random alphanumeric characters.
38+
# Generate a URL-safe token of random alphanumeric characters.
4139
>>> secrets.token_urlsafe(16)
4240
'gkSUKRdiPDHqmImPi2HMnw'
4341
```
4442

45-
4643
If you are writing security-sensitive applications, you will certainly want to read the [full documentation][secrets], which gives further advice and examples.
4744

48-
4945
[PEP506]: https://peps.python.org/pep-0506/
5046
[pseudo-random-numbers]: https://www.khanacademy.org/computing/computer-science/cryptography/crypt/v/random-vs-pseudorandom-number-generators
5147
[secrets]: https://docs.python.org/3/library/secrets.html

concepts/secrets/introduction.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ The [`secrets`][secrets] module overlaps with `random` in some of its functional
77
- `random` is optimized for high performance in modelling and simulation, with "good enough" pseudo-random number generation.
88
- `secrets` is designed to be crytographically secure for applications such as password hashing, security token generation, and account authentication.
99

10-
1110
Further details on why the addition of the `secrets` module proved necessary are given in [PEP 506][PEP506].
1211

1312
If you are writing security-sensitive applications, you will certainly want to read the [full documentation][secrets], which gives further advice and examples.
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
{
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.",
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.",
33
"authors": [
44
"valentin-p"
55
],
66
"contributors": [
77
"j08k",
88
"BethanyG",
9-
"BNAndras"
9+
"BNAndras",
10+
"yrahcaz7"
1011
]
1112
}

0 commit comments

Comments
 (0)