python-cryptography

PyJWT decoding showing error "The specified alg value is not allowed" for 'RS512' even if it is listed in supported algorithms

PyJWT decoding showing error "The specified alg value is not allowed" for 'RS512' even if it is listed in supported algorithms Question: I’m calling the decode function like that: payload = jwt.decode(token, cert[‘key’], algorithms=[‘RS512’], audience=aud, leeway=0, ) The error I m having: File "/usr/local/lib/python3.9/site-packages/jwt/api_jws.py", line 292, in _verify_signature raise InvalidAlgorithmError("The specified alg value is not …

Total answers: 1

Firebase credentials as Python environment variables: Could not deserialize key data

Firebase credentials as Python environment variables: Could not deserialize key data Question: I’m developing a Python web app with a Firestore realtime database using the firebase_admin library. The Firestore key comes in form of a .json file containing 10 variables. However, I want to store some of these variables as environment variables so they are …

Total answers: 2

Python string with byte array to byte array

Python string with byte array to byte array Question: ciphertext = base64.b64decode(xxxxxx) //output is b’148,240,50,66,81,26,240,2,101,31′ bytearray(ciphertext) // output is bytearray(b’148,240,50,66,81,26,240,2,101,31′) What am looking for is output of bytearray([148,240,50,66,81,26,240,2,101,31]) Full code: ciphertext = base64.b64decode("MTQ4LDI0MCw1MCw2Niw4MSwyNiwyNDAsMiwxMDEsMzEsMjM3LDEwMSw4OCwxODQsMTQsMTM1LDEzMCw0Miw0NywxODksMTkyLDE1MSw0OCwyMjQsMTU1LDQxLDM5LDE0MywyMDksMTA0LDE5NywyMywxMDUsMjMsMTYzLDUzLDQsMTQ0LDE2MSwxNDgsMjMwLDI1NCwxMzQsMjEzLDE3NCwyNDcsMTkxLDUyLDY0LDE2LDYzLDk0LDE1NCwxMzMsMzksMTMzLDIyNCwxODcsMTE0LDE1OCwyMzksMzUsMTUxLDM4LDE3NSwxNTIsOTksMTAyLDIxNCwyNTEsMTk0LDIxMywxNzMsMTc0LDcyLDIyNSwyMDIsMTcyLDE1NCw4OCwxMzksMTE1LDIzNywyMzYsMTIxLDAsMjE0LDIxNiwxOTYsNDAsMzgsMjA0LDgzLDEzNiwxNjAsMTczLDY5LDcsMzgsMjI1LDExOCw0OSw0OCw3MCwxNjYsMTIxLDI0NSwxOTEsMTgzLDEyMiwxOTksMTg3LDgsNDMsNDUsOTMsMTI0LDIxNSwxNjEsNzAsMjU0LDI2LDE4OCwxMywyMjYsMTMxLDMsNCw0MywxOTgsMjEyLDEwMywxMTcsMjE1LDEyNywyNDMsMzksNzIsNzYsMTE0LDUwLDE5Niw1NSwxMjEsODYsMjUxLDUzLDI0MiwzMCwxMDksNDcsMjEwLDI1MywxNjMsOTAsOTgsMTQsNjAsMTE1LDc1LDE0OSwyMTAsMTc1LDI2LDEyNCwyMjgsMjQ3LDIwLDIwMyw5NiwyMTAsMjYsODEsNjUsMTg4LDEyMSwxMjgsOTEsMTA3LDE2OCwxMywyMDcsMTc1LDE3MCwyNTUsMjM2LDE0OSwxMDksNTksMjQsMTcyLDExLDU4LDEzLDAsMTUyLDExNiwxMTAsMTExLDIyLDIzMSwzLDIzNyw0Miw4MSw3Nyw2MywyMjMsMTAzLDEwOSw1NiwxNTgsNDMsMjA2LDIwMiwzOCwxNDgsMTM3LDE4OSwyMTQsMjE2LDkwLDE4LDIyNCwyNTQsMzcsMTA5LDE4LDg0LDIyMiwyMDksMjUsNTMsMjE5LDE2OSwyMTEsNTAsMTgyLDQwLDExMiwyMDksMzEsNTIsMjEsNTMsOTgsMTIyLDI1NCwxMDgsMzksMzgsMTM0LDE1MCwxMzksMTk0LDMw=") Asked By: cidodo7472 || Source Answers: Replace: bytearray(ciphertext) with: bytearray(map(int, ciphertext.split(b’,’))) # Or if you prefer genexprs: bytearray(int(x) for x in ciphertext.split(b’,’)) …

Total answers: 1

CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team

CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team Question: I upgraded my system from python 2 to python 3, and now when I run my code: from cryptography.hazmat.backends import default_backend I am getting this error /usr/local/lib/python3.6/site-packages/paramiko/transport.py:33: CryptographyDeprecationWarning: Python 3.6 is no longer supported by the Python core team. Therefore, support for …

Total answers: 3

Shared key generation from EC with pycryptodome

Shared key generation from EC with pycryptodome Question: I’m curently working on a project were i need to compute an hkdf symetric key. To do that i need to generate a shared secret from the private key and an ephemeral public key. For the rest of my work i did use pycryptodome but i can’t …

Total answers: 1

Python ECDH with Cryptography Problem Public Key

Python ECDH with Cryptography Problem Public Key Question: Currently I started working with the cryptography framework on python. I’m trying to build a SSH Suit by my own but I ran into some problem with the library. I’m trying to build my own Elliptic Curve Key Exchange Init Packet (with scapy). I’m trying to do …

Total answers: 1

ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly

ERROR: Could not build wheels for cryptography which use PEP 517 and cannot be installed directly Question: I get an error when pip builds wheels for the cryptography package. Error: LINK : fatal error LNK1181: cannot open input file ‘libssl.lib’ error: command ‘C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Tools\MSVC\14.16.27023\bin\HostX86\x86\link.exe’ failed with exit status 1181 —————————————- ERROR: Failed …

Total answers: 14

Is it possible to save a fernet key for a later session?

Is it possible to save a fernet key for a later session? Question: I am very new at python, I was working on a program that encrypts a text string, then saves it to a file. My program works perfectly when I encrypt then decrypt it in the same session. What I would like to …

Total answers: 2

Sign a byte string with SHA256 in Python

Sign a byte string with SHA256 in Python Question: Currently I have some code that signs a byte string with the SHA256 algorithm using the native OpenSSL binary, the code calls an external process, sends the parameters, and receive the result back into the Python code. The current code is as follows: signed_digest_proc = subprocess.Popen( …

Total answers: 1