rsa

Encrypting java JWEObject with RSA in python

Encrypting java JWEObject with RSA in python Question: I asked a while ago how to do something similar: Decrypting and encrypting java JWEObject with algorithm RSA-OAEP-256 on python Now I have a different encryption key and that code is not working for me anymore. I need to be able to encrypt my data: {"value": "Object …

Total answers: 1

Python squaring a square rooted number gives a different result although it should be the original number

Python squaring a square rooted number gives a different result although it should be the original number Question: Im working on RSA so I’m dealing with very large numbers (308 digits). In RSA a number N is the product of 2 primes p and q. My N: 20254083928313901046078299908836135556415829454193867459405514358320313885965296062600909040071281223146837763723113350068483510086809787065437344845044248205975654791622356467691953988928774211033663314876745580293750456921795999384782277674803240671474563131823612882192899349325870727676292313218782419561 For the task I’m completing, I have …

Total answers: 2

How to read python RSA Pem key correctly?

How to read python RSA Pem key correctly? Question: I want to read a RSA public key from database. I am using rsa python lib. public key is stored as a text. when i print type of key and it value i get (var name is pk) (print(type(pk), pk)): <class ‘bytes’> b’—–BEGIN RSA PUBLIC KEY—–\nMIIBCgKCAQEAmXSSnzrY2/z7zLZuF7KZZFP7mbmYEeRhpQsQfpEv4t/Fvz6/g5QO\n79ZcGBd6wOxshGFSLYPAl1oB3GPNkwr+mdjqtSIXzhhvW9Xjjx4dIUVn7JrtsBXi\nr7aG85HEYyk3LLBoWus9X+XJ/tiHlQzqY2o8+dO31X4HBeWzflczrNXN3ntGGf4S\noAaqJKlkUSxdGexvJUhmli9x+CKQoojFHxHfq1IZldRMPb8O8N6RSZIA5t2n6vpw\nGPx8tBm7Eub5nVi+sACHS6rLdAHcd+D4tBCjp9wp2dGu77/oRUI7aomRFRMmBf7/\nZkHHzor2kGIZ3fYHEL7g+WkVsxqGXblG8QIDAQAB\n—–END …

Total answers: 1

How to get Steam web session cookie programatically

How to get Steam web session cookie programatically Question: I’m currently trying to make a steam web api (the unofficial one which is partially documented here: https://github.com/Revadike/InternalSteamWebAPI/wiki) wrapper. Like with every other unofficial api you have to get a sessionID to get access to certain api calls (for example selling items etc) When actually implementing …

Total answers: 2

Set SFTP server host public key

Set SFTP server host public key in Paramiko with non-default port Question: I am trying to set a known host public key before establishing the connection. I have tried using the public key file the partner shared with me, but I wasn’t able to connect, so now I am trying to add the key which …

Total answers: 1

How to generate a byte string consisting of random nonzero bytes using Python?

How to generate a byte string consisting of random nonzero bytes using Python? Question: As part of implementing the PKCS #1 v1.5 padding scheme for RSA, I need to generate an octet string of length n consisting of pseudo-randomly generated nonzero octets. I’m looking for the best way to do this using Python. This is …

Total answers: 2

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

Python 3 UnboundLocalError: local variable referenced before assignment in try statement

Python 3 UnboundLocalError: local variable referenced before assignment in try statement Question: I’m trying to make a program that handles RSA encryption and decryption for sending messages using the rsa library. Currently I’m implementing it to use only 1 key pair, but it’ll be changed later on. I’m having some trouble with the logic to …

Total answers: 4

How to load a public RSA key into Python-RSA from a file?

How to load a public RSA key into Python-RSA from a file? Question: I generated a private and a public key using OpenSSL with the following commands: openssl genrsa -out private_key.pem 512 openssl rsa -in private_key.pem -pubout -out public_key.pem I then tried to load them with a python script using Python-RSA: import os import rsa …

Total answers: 5