Skip to content

Instantly share code, notes, and snippets.

@paulsc
Last active October 23, 2022 05:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulsc/07c7741b11ca3897c3c0acafc9e642bd to your computer and use it in GitHub Desktop.
Save paulsc/07c7741b11ca3897c3c0acafc9e642bd to your computer and use it in GitHub Desktop.
def encodePkcs1Suffix(self, message):
messageHash = self.hashAlg.digester(message.encode("utf-8")).digest()
if messageHash[-1] & 0x01 != 0x01:
print(
"Hash value must be uneven. Try a different message or a different
hash algorithm",
file=stderr,
)
exit(1)
suffix = bytes([0]) + self.hashAlg.digestInfo + messageHash
return suffix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment