Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitf254895

Browse files
committed
Usebytes.find() instead ofbytes.index()
Use `bytes.find()` instead of `bytes.index()`, as the former doesn't raisean exception when the to-be-found byte doesn't exist.
1 parent240b0d8 commitf254895

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

‎rsa/pkcs1.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,8 @@ def decrypt(crypto: bytes, priv_key: key.PrivateKey) -> bytes:
258258
cleartext_marker_bad=notcompare_digest(cleartext[:2],b'\x00\x02')
259259

260260
# Find the 00 separator between the padding and the message
261-
try:
262-
sep_idx=cleartext.index(b'\x00',2)
263-
exceptValueError:
264-
sep_idx=-1
261+
sep_idx=cleartext.find(b'\x00',2)
262+
265263
# sep_idx indicates the position of the `\x00` separator that separates the
266264
# padding from the actual message. The padding should be at least 8 bytes
267265
# long (see https://tools.ietf.org/html/rfc8017#section-7.2.2 step 3), which

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp