11# SOME DESCRIPTIVE TITLE.
2- # Copyright (C) 2001-2025 , Python Software Foundation
2+ # Copyright (C) 2001-2026 , Python Software Foundation
33# This file is distributed under the same license as the Python package.
44# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
55#
@@ -11,7 +11,7 @@ msgid ""
1111msgstr ""
1212"Project-Id-Version : Python 3.13\n "
1313"Report-Msgid-Bugs-To : \n "
14- "POT-Creation-Date : 2025 -02-21 14:16 +0000\n "
14+ "POT-Creation-Date : 2026 -02-09 15:32 +0000\n "
1515"PO-Revision-Date : 2025-09-15 01:04+0000\n "
1616"Last-Translator : python-doc bot, 2025\n "
1717"Language-Team : Chinese (China) (https://app.transifex.com/python-doc/teams/5390/zh_CN/)\n "
@@ -90,60 +90,58 @@ msgid ""
9090msgstr ":mod:`secrets` 模块提供了生成安全 Token 的函数,适用于密码重置、密保 URL 等应用场景。"
9191
9292#: ../../library/secrets.rst:67
93+ msgid "Return a random byte string containing *nbytes* number of bytes."
94+ msgstr ""
95+
96+ #: ../../library/secrets.rst:69 ../../library/secrets.rst:83
97+ #: ../../library/secrets.rst:97
9398msgid ""
94- "Return a random byte string containing *nbytes* number of bytes. If *nbytes* "
95- " is ``None`` or not supplied, a reasonable default is used ."
99+ "If *nbytes* is not specified or ``None``, :const:`DEFAULT_ENTROPY` is used "
100+ "instead ."
96101msgstr ""
97- "返回含 *nbytes* 个字节的随机字节字符串。如果未提供 *nbytes*,或*nbytes* 为 ``None``,则使用合理的默认值。"
98102
99- #: ../../library/secrets.rst:71
103+ #: ../../library/secrets.rst:72
100104msgid ""
101105">>> token_bytes(16)\n"
102106"b'\\ xebr\\ x17D*t\\ xae\\ xd4\\ xe3S\\ xb6\\ xe2\\ xebP1\\ x8b'"
103107msgstr ""
104108">>> token_bytes(16)\n"
105109"b'\\ xebr\\ x17D*t\\ xae\\ xd4\\ xe3S\\ xb6\\ xe2\\ xebP1\\ x8b'"
106110
107- #: ../../library/secrets.rst:79
111+ #: ../../library/secrets.rst:80
108112msgid ""
109113"Return a random text string, in hexadecimal. The string has *nbytes* random"
110- " bytes, each byte converted to two hex digits. If *nbytes* is ``None`` or "
111- "not supplied, a reasonable default is used."
114+ " bytes, each byte converted to two hex digits."
112115msgstr ""
113- "返回十六进制随机文本字符串。字符串有 *nbytes* 个随机字节,每个字节转换为两个十六进制数码。未提供 *nbytes* 或为 ``None`` "
114- "时,则使用合理的默认值。"
115116
116- #: ../../library/secrets.rst:83
117+ #: ../../library/secrets.rst:86
117118msgid ""
118119">>> token_hex(16)\n"
119120"'f9bf78b9a18ce6d46a0cd2b0b86df9da'"
120121msgstr ""
121122">>> token_hex(16)\n"
122123"'f9bf78b9a18ce6d46a0cd2b0b86df9da'"
123124
124- #: ../../library/secrets.rst:90
125+ #: ../../library/secrets.rst:93
125126msgid ""
126127"Return a random URL-safe text string, containing *nbytes* random bytes. The"
127128" text is Base64 encoded, so on average each byte results in approximately "
128- "1.3 characters. If *nbytes* is ``None`` or not supplied, a reasonable "
129- "default is used."
129+ "1.3 characters."
130130msgstr ""
131- "返回安全的 URL 随机文本字符串,包含 *nbytes* 个随机字节。文本用 Base64 编码,平均来说,每个字节对应 1.3 个结果字符。未提供 "
132- "*nbytes* 或为 ``None`` 时,则使用合理的默认值。"
133131
134- #: ../../library/secrets.rst:95
132+ #: ../../library/secrets.rst:100
135133msgid ""
136134">>> token_urlsafe(16)\n"
137135"'Drmhze6EPcv0fN_81Bj-nA'"
138136msgstr ""
139137">>> token_urlsafe(16)\n"
140138"'Drmhze6EPcv0fN_81Bj-nA'"
141139
142- #: ../../library/secrets.rst:102
140+ #: ../../library/secrets.rst:107
143141msgid "How many bytes should tokens use?"
144142msgstr "Token 应当使用多少个字节?"
145143
146- #: ../../library/secrets.rst:104
144+ #: ../../library/secrets.rst:109
147145msgid ""
148146"To be secure against `brute-force attacks "
149147"<https://en.wikipedia.org/wiki/Brute-force_attack>`_, tokens need to have "
@@ -157,7 +155,7 @@ msgstr ""
157155" 的随机性必须足够高。随着计算机推衍能力的不断提升,随机性的安全标准也要不断提高。比如 2015 年,32 字节(256 位)的随机性对于 "
158156":mod:`secrets` 模块的典型用例就已经足够了。"
159157
160- #: ../../library/secrets.rst:112
158+ #: ../../library/secrets.rst:117
161159msgid ""
162160"For those who want to manage their own token length, you can explicitly "
163161"specify how much randomness is used for tokens by giving an :class:`int` "
@@ -167,23 +165,28 @@ msgstr ""
167165"要自行管理 Token 长度的用户,可以通过为 ``token_*`` 函数指定 :class:`int` 参数显式指定 Token "
168166"要使用多大的随机性。该参数以字节数表示随机性大小。"
169167
170- #: ../../library/secrets.rst:117
168+ #: ../../library/secrets.rst:122
171169msgid ""
172170"Otherwise, if no argument is provided, or if the argument is ``None``, the "
173- "``token_*`` functions will use a reasonable default instead."
174- msgstr "反之,如果未提供参数,或参数为 ``None``,则 ``token_*`` 函数将使用合理的默认值。 "
171+ "``token_*`` functions uses :const:`DEFAULT_ENTROPY` instead."
172+ msgstr ""
175173
176- #: ../../library/secrets.rst:122
174+ #: ../../library/secrets.rst:127
177175msgid ""
178- "That default is subject to change at any time, including during maintenance "
179- "releases."
180- msgstr "该默认值随时可能会改变,比如,版本更新的时候。"
176+ "Default number of bytes of randomness used by the ``token_*`` functions."
177+ msgstr ""
181178
182- #: ../../library/secrets.rst:127
179+ #: ../../library/secrets.rst:129
180+ msgid ""
181+ "The exact value is subject to change at any time, including during "
182+ "maintenance releases."
183+ msgstr ""
184+
185+ #: ../../library/secrets.rst:134
183186msgid "Other functions"
184187msgstr "其他功能"
185188
186- #: ../../library/secrets.rst:131
189+ #: ../../library/secrets.rst:138
187190msgid ""
188191"Return ``True`` if strings or :term:`bytes-like objects <bytes-like object>`"
189192" *a* and *b* are equal, otherwise ``False``, using a \" constant-time "
@@ -195,21 +198,21 @@ msgstr ""
195198"``False``,使用了“常数时间比较”来降低 `定时攻击 <https://codahale.com/a-lesson-in-timing-"
196199"attacks/>`_ 的风险。请参阅 :func:`hmac.compare_digest` 了解更多细节。"
197200
198- #: ../../library/secrets.rst:140
201+ #: ../../library/secrets.rst:147
199202msgid "Recipes and best practices"
200203msgstr "应用技巧与最佳实践"
201204
202- #: ../../library/secrets.rst:142
205+ #: ../../library/secrets.rst:149
203206msgid ""
204207"This section shows recipes and best practices for using :mod:`secrets` to "
205208"manage a basic level of security."
206209msgstr "本节展示了一些使用 :mod:`secrets` 管理基本安全级别的应用技巧和最佳实践。"
207210
208- #: ../../library/secrets.rst:145
211+ #: ../../library/secrets.rst:152
209212msgid "Generate an eight-character alphanumeric password:"
210213msgstr "生成长度为八个字符的字母数字密码:"
211214
212- #: ../../library/secrets.rst:147
215+ #: ../../library/secrets.rst:154
213216msgid ""
214217"import string\n"
215218"import secrets\n"
@@ -221,7 +224,7 @@ msgstr ""
221224"alphabet = string.ascii_letters + string.digits\n"
222225"password = ''.join(secrets.choice(alphabet) for i in range(8))"
223226
224- #: ../../library/secrets.rst:157
227+ #: ../../library/secrets.rst:164
225228msgid ""
226229"Applications should not :cwe:`store passwords in a recoverable format "
227230"<257>`, whether plain text or encrypted. They should be salted and hashed "
@@ -230,13 +233,13 @@ msgstr ""
230233"应用程序不应该 :cwe:`以可恢复的格式存储密码 <257>`,无论是纯文本的还是加密的。 "
231234"它们应当使用高加密强度的单向(不可逆)哈希函数加盐并执行哈希运算。"
232235
233- #: ../../library/secrets.rst:163
236+ #: ../../library/secrets.rst:170
234237msgid ""
235238"Generate a ten-character alphanumeric password with at least one lowercase "
236239"character, at least one uppercase character, and at least three digits:"
237240msgstr "生成长度为十个字符的字母数字密码,包含至少一个小写字母,至少一个大写字母以及至少三个数字:"
238241
239- #: ../../library/secrets.rst:167
242+ #: ../../library/secrets.rst:174
240243msgid ""
241244"import string\n"
242245"import secrets\n"
@@ -258,11 +261,11 @@ msgstr ""
258261" and sum(c.isdigit() for c in password) >= 3):\n"
259262" break"
260263
261- #: ../../library/secrets.rst:180
264+ #: ../../library/secrets.rst:187
262265msgid "Generate an `XKCD-style passphrase <https://xkcd.com/936/>`_:"
263266msgstr "生成 `XKCD 风格的密码串 <https://xkcd.com/936/>`_:"
264267
265- #: ../../library/secrets.rst:182
268+ #: ../../library/secrets.rst:189
266269msgid ""
267270"import secrets\n"
268271"# On standard Linux systems, use a convenient dictionary file.\n"
@@ -278,13 +281,13 @@ msgstr ""
278281" words = [word.strip() for word in f]\n"
279282" password = ' '.join(secrets.choice(words) for i in range(4))"
280283
281- #: ../../library/secrets.rst:192
284+ #: ../../library/secrets.rst:199
282285msgid ""
283286"Generate a hard-to-guess temporary URL containing a security token suitable "
284287"for password recovery applications:"
285288msgstr "生成临时密保 URL,包含密码恢复应用的安全 Token:"
286289
287- #: ../../library/secrets.rst:195
290+ #: ../../library/secrets.rst:202
288291msgid ""
289292"import secrets\n"
290293"url = 'https://example.com/reset=' + secrets.token_urlsafe()"
0 commit comments