cryptography

Adobe Acrobat Reader can't open PKCS#12 file with correct password

Adobe Acrobat Reader can't open PKCS#12 file with correct password Question: I’m using the cryptography library to generate certificates, but I’m having trouble with it, so let me explain the steps I take. The problem is that the final PKCS#12 file can’t be imported to Adobe Acrobat Reader even though I enter the correct password. …

Total answers: 1

Proper data encryption with a user-set password in python3

Proper data encryption with a user-set password in python3 Question: I have been looking for a proper data encryption library in python for a long while, today I needed it once again, cannot find anything, so is there any way to encrypt data using a user-set password, if I find something it’s usually insecure, if …

Total answers: 3

SHA256 Personal Implementation Is Only Returning The Correct Hash Value For Input Messages With A Block Size That Doesn't Exceed 512 Bits

SHA256 Personal Implementation Is Only Returning The Correct Hash Value For Input Messages With A Block Size That Doesn't Exceed 512 Bits Question: SOLVED For a while I’ve been working on my own implementation of the SHA256 in Python to entertain my interest in mathematics and programming. The problem I’m currently struggling with is that …

Total answers: 1

How to extract the signature from a p7s file?

How to extract the signature from a p7s file? Question: I need the Python code to extract from the p7s file the signature resulting from digitally signing a document, in both situations where the payload is inside of, and external to, the p7s file. I have tried several crypto packages (PyOpenSSL, PyCripto, Cryptography, ASN1Crypto, and …

Total answers: 2

Fernet key must be 32 url-safe base64-encoded bytes

Fernet key must be 32 url-safe base64-encoded bytes Question: import certifi from pymongo import MongoClient import os import platform from cryptography.fernet import Fernet cluster = MongoClient("(database string)", tlsCAFile=certifi.where()) db = cluster["db"] pass_collection = db["password"] def clear(): if platform.system() == "Windows": os.system(‘cls’) else: os.system(‘clear’) while True: clear() print(”” /$$$$$$ /$$$$$$$ /$$ /$$ /$$__ $$| $$__ $$| …

Total answers: 1

cryptography.fernet.InvalidToken problem with cryptography

cryptography.fernet.InvalidToken problem with cryptography Question: Getting this error when trying to run this: File "Test Files.py", line 502, in decryptdefault decrypted = fernet.decrypt(d) File "/usr/lib/python3/dist-packages/cryptography/fernet.py", line 74, in decrypt timestamp, data = Fernet._get_unverified_token_data(token) File "/usr/lib/python3/dist-packages/cryptography/fernet.py", line 92, in _get_unverified_token_data raise InvalidToken cryptography.fernet.InvalidToken FYI dk variable is defined with key (default key) dk = ‘niwaXsYbDiAxmLiqRiFbDa_8gHio15sNQ6ZO-sQ0nR4=’ # …

Total answers: 1

How do I find Legendre's Symbol?

How do I find Legendre's Symbol? Question: Given a 1024 bit modulo and several long integers, I wanted to find out which of these values is a quadratic residue. The Legendre Symbol is supposed to return -1,0, or 1 and yet my code returns values several orders of magnitude larger than these. p = 101524035174539890485408575671085261788758965189060164484385690801466167356667036677932998889725476582421738788500738738503134356158197247473850273565349249573867251280253564698939768700489401960767007716413932851838937641880157263936985954881657889497583485535527613578457628399173971810541670838543309159139 …

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

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

Compute ecies hkdf symetric key with pycryptodome

Compute ecies hkdf symetric key with pycryptodome Question: Context: i’m working on making a python version of paymentmethodtoken from the google tink library to work with gpay messages. For that i use only python and PyCryptodome. With that said i’m currently trying to implement an equivalent of the kem function: private byte[] kem(JsonObject json, final …

Total answers: 1