Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants