Last active
January 14, 2021 11:22
-
-
Save SuperCipher/73317ce32b969b35812dfaef36aafd73 to your computer and use it in GitHub Desktop.
coincurve13.0.0 generate hash message from private key
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
coincurve 13.0.0 pypi_0 pypi | |
Python 3.7.4 (default, Aug 13 2019, 15:17:50) | |
[Clang 4.0.1 (tags/RELEASE_401/final)] :: Anaconda, Inc. on darwin | |
Type "help", "copyright", "credits" or "license" for more information. | |
>>> from cryptography.hazmat.backends import default_backend | |
>>> from cryptography.hazmat.primitives.asymmetric import rsa | |
>>> private_key = rsa.generate_private_key( | |
... public_exponent=65537, | |
... key_size=2048, | |
... backend=default_backend() | |
... ) | |
>>> from cryptography.hazmat.primitives import hashes | |
>>> from cryptography.hazmat.primitives.asymmetric import padding | |
>>> | |
>>> message = b"A message I want to sign" | |
>>> signature = private_key.sign( | |
... message, | |
... padding.PSS( | |
... mgf=padding.MGF1(hashes.SHA256()), | |
... salt_length=padding.PSS.MAX_LENGTH | |
... ), | |
... hashes.SHA256() | |
... ) | |
>>> signature | |
b'Y\xf5\xe8\x80\xf6\xd2\xa8D:\xbc\xbd\x0b\xf5\x1bM\xbf7`\x87\x17\xb5\x9e\xab\xaes\xb3Z\xb81\xa4\xe6\xe8\xc2\xbe>\x99\xf1\x0f\x85\xc6\x82\xfa\xebL\n\x1d\xc5\xa9\xfa\xa6p\xf7g\x98FBs\x81\xf5\x8f\x9c=\xc7\x9aW\x14\x11\xbb\xde\xbe\xdd\xd8y\x81\\\x1cpj\xe6\xc3\xae\xca\x16lf]w\xe1\xd5Z\xd9\xfdH\xf1\xd5\xde \x8d\xc5\x8d\x06v>\x98p\xf6\xdd,U\x81\xe5\xb3h?`\xce\xee\x12\xf1#\x12\x80\x04\'\x86tHh\xbf/\xc2\x9d\xbe\xc9{\xc1\xaf\x13n-0\xf0\x91\x91M2\x83z\x90*^\xa2\x9d\x8e\xcf\xb3\xa1jX0\xdf\xa4Ra\xe8`\x96\x8e\x0cP\xd3\xe9\x90Q\xb9y"\xff\x16q\x1f\\h\x12\xb8 \'\xdd\x13\x06\x03\x92\x9c\xae=]g\x9e`\xb2\xa5\xad\xd7\xd26ug}\xc0\xaa\xc2I\xb0\x0c\x99\xddc\x1e\xe1\xf6\x16\xb5\xa9](US\xb0}\x9f\xf6\x18k\x8d\x8f\xcf\xc1\xa4\x03\xde\x8fID\x11\xde\xab\xcd\x96\xaf\x1cd\xa7\xa9\xacX\x8b' | |
>>> import base64 | |
>>> print( base64.urlsafe_b64encode(signature)) | |
b'WfXogPbSqEQ6vL0L9RtNvzdghxe1nquuc7NauDGk5ujCvj6Z8Q-FxoL660wKHcWp-qZw92eYRkJzgfWPnD3HmlcUEbvevt3YeYFcHHBq5sOuyhZsZl134dVa2f1I8dXeII3FjQZ2Pphw9t0sVYHls2g_YM7uEvEjEoAEJ4Z0SGi_L8Kdvsl7wa8Tbi0w8JGRTTKDepAqXqKdjs-zoWpYMN-kUmHoYJaODFDT6ZBRuXki_xZxH1xoErggJ90TBgOSnK49XWeeYLKlrdfSNnVnfcCqwkmwDJndYx7h9ha1qV0oVVOwfZ_2GGuNj8_BpAPej0lEEd6rzZavHGSnqaxYiw==' | |
>>> print( base64.urlsafe_b64encode(b'0E\x02!\x00\xa3D/\xaa\xe2\'Q\xdc\xf9\xe6\xc7\xa3mA\xec\x18\xf3|\xd3z_\xf19\x80\xd9\xe7\xab6b*\xdb\x13\x02 \\\xe4\xc8\xee\x16\x9b\xc7\xf3;\x11\xed,\x19\xe0\xcc\xdb1ur\xbb\xeax\xec"\xac\xdb\xcb(\'0n\xa1')) | |
b'MEUCIQCjRC-q4idR3Pnmx6NtQewY83zTel_xOYDZ56s2YirbEwIgXOTI7habx_M7Ee0sGeDM2zF1crvqeOwirNvLKCcwbqE=' | |
>>> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment