public-key-encryption

How to encrypt a string using python Openssl public key?

How to encrypt a string using python Openssl public key? Question: My current code to generate an OpenSSL public-private key pair: import OpenSSL key = OpenSSL.crypto.PKey() key.generate_key(OpenSSL.crypto.TYPE_RSA, 2048) public_key = OpenSSL.crypto.dump_publickey(OpenSSL.crypto.FILETYPE_PEM, key) private_key = OpenSSL.crypto.dump_privatekey(OpenSSL.crypto.FILETYPE_PEM, key) print(public_key, private_key, sep="n") Asked By: Flow || Source Answers: The documentation recommends that you call key.to_cryptography_key() to get a …

Total answers: 1

Generate a public key with a predefined modulus and exponent

Generate a public key with a predefined modulus and exponent Question: "n": "rKZ-1zdz_CoLekSynOtyWv6cPSSkV28Kb9kZZHyYL-yhkKnH_bHl8OpWiGxQiKP0ulLRIaq1IhSMetkZ8FfXH-iptIDu4lPb8gt0HQYkjcy3HoaKRXBw2F8fJQO4jQ-ufR4l-E0HRqwLywzdtAImNWmju3A4kx8s0iSGHGSHyE4EUdh5WKt-NMtfUPfB5v9_2bC-w6wH7zAEsI5nscMXnvz1u8w7g2_agyhKSK0D9OkJ02w3I4xLMlrtKEv2naoBGerWckKcQ1kBYUh6WASPdvTqX4pcAJi7Tg6jwQXIP1aEq0JU8C0zE3d33kaMoCN3SenIxpRczRzUHpbZ-gk5PQ", "e": "AQAB", How can I generate a public key from these values? Preferable via python or Linux programs. I’m sorry if the question is nonsense because of invalid values. The source is here. Asked By: salius || Source Answers: In Python, you …

Total answers: 1

How to get an elliptic curve public key from a private key

How to get an elliptic curve public key from a private key Question: So, I need to get a public key from a corresponding 256 bit number using ECC spec256k1. So, lets say I get a private key using a sha256 from any passphrase, like this: >>> import hashlib >>> private_key = hashlib.sha3_256(b”Led Zeppelin – …

Total answers: 3

Cube root modulo P — how do I do this?

Cube root modulo P — how do I do this? Question: I am trying to calculate the cube root of a many-hundred digit number modulo P in Python, and failing miserably. I found code for the Tonelli-Shanks algorithm which supposedly is simple to modify from square roots to cube roots, but this eludes me. I’ve …

Total answers: 4

How to do PGP in Python (generate keys, encrypt/decrypt)

How to do PGP in Python (generate keys, encrypt/decrypt) Question: I’m making a program in Python to be distributed to windows users via an installer. The program needs to be able to download a file every day encrypted with the user’s public key and then decrypt it. So I need to find a Python library …

Total answers: 7