Skip to content
This repository was archived by the owner on Apr 20, 2025. It is now read-only.

Typographical mistake in examples of documentation #170

Closed
gridhead opened this issue Dec 20, 2020 · 1 comment
Closed

Typographical mistake in examples of documentation #170

gridhead opened this issue Dec 20, 2020 · 1 comment

Comments

@gridhead
Copy link

At https://stuvel.eu/python-rsa-doc/usage.html#signing-and-verification, the first example in this section states the following.

(pubkey, privkey) = rsa.newkeys(512)
message = 'Go left at the blue tree'
signature = rsa.sign(message, privkey, 'SHA-1')

and the second example states the following.

message = 'Go left at the blue tree'
hash = rsa.compute_hash(message, 'SHA-1')
signature = rsa.sign_hash(hash, privkey, 'SHA-1')

If these two are followed as-is, it would result as an AssertionError.

To solve this, we would need to add encoding

at L#2 of the first example,

(pubkey, privkey) = rsa.newkeys(512)
message = 'Go left at the blue tree'.encode('utf-8')
signature = rsa.sign(message, privkey, 'SHA-1')

and

at L#1 of the second example.

message = 'Go left at the blue tree'.encode('utf-8')
hash = rsa.compute_hash(message, 'SHA-1')
signature = rsa.sign_hash(hash, privkey, 'SHA-1')

Such kind of corrections is also needed in other examples of the same section.

@sybrenstuvel
Copy link
Owner

Thanks for the report!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants