@@ -170,7 +170,7 @@ You can create a detached signature for a message using the
170
170
:py:func: `rsa.sign ` function:
171
171
172
172
>>> (pubkey, privkey) = rsa.newkeys(512 )
173
- >>> message = ' Go left at the blue tree'
173
+ >>> message = ' Go left at the blue tree' .encode()
174
174
>>> signature = rsa.sign(message, privkey, ' SHA-1' )
175
175
176
176
This hashes the message using SHA-1. Other hash methods are also
@@ -182,21 +182,21 @@ It is possible to calculate the hash and signature in separate operations
182
182
private key on remote server). To hash a message use the :py:func: `rsa.compute_hash `
183
183
function and then use the :py:func: `rsa.sign_hash ` function to sign the hash:
184
184
185
- >>> message = ' Go left at the blue tree'
185
+ >>> message = ' Go left at the blue tree' .encode()
186
186
>>> hash = rsa.compute_hash(message, ' SHA-1' )
187
187
>>> signature = rsa.sign_hash(hash , privkey, ' SHA-1' )
188
188
189
189
In order to verify the signature, use the :py:func: `rsa.verify `
190
190
function. This function returns True if the verification is successful:
191
191
192
- >>> message = ' Go left at the blue tree'
192
+ >>> message = ' Go left at the blue tree' .encode()
193
193
>>> rsa.verify(message, signature, pubkey)
194
194
True
195
195
196
196
Modify the message, and the signature is no longer valid and a
197
197
:py:class: `rsa.pkcs1.VerificationError ` is thrown:
198
198
199
- >>> message = ' Go right at the blue tree'
199
+ >>> message = ' Go right at the blue tree' .encode()
200
200
>>> rsa.verify(message, signature, pubkey)
201
201
Traceback (most recent call last):
202
202
File "<stdin>", line 1, in <module>
0 commit comments