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

Typographical mistake in examples of documentation #170

@gridhead

Description

@gridhead

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions