Created
July 31, 2020 06:37
-
-
Save shuax/8e7d0132a549e6cfc2e10a94d8bfe918 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| from Crypto.PublicKey import ECC | |
| from Crypto.Hash import SHA256 | |
| from Crypto.Signature import DSS | |
| text = b"123456" | |
| h = SHA256.new(text) | |
| print(h) | |
| key = ECC.generate(curve='P-256') | |
| # print(key) | |
| print(key.export_key(format="PEM")) | |
| # print() | |
| # print(key.public_key().export_key(format="PEM")) | |
| # print() | |
| # print(dir(key)) | |
| signer = DSS.new(key, 'fips-186-3') | |
| signature = signer.sign(h) | |
| print(signature) | |
| text = b"123456" | |
| h = SHA256.new(text) | |
| verifier = DSS.new(key.public_key(), 'fips-186-3') | |
| print(verifier.verify(h, signature)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment