cryptography

Python: finding all generators for a cyclic group

Python: finding all generators for a cyclic group Question: Take a cyclic group Z_n with the order n. The elements are: Z_n = {1,2,…,n-1} For each of the elements, let us call them a, you test if a^x % n gives us all numbers in Z_n; x is here all numbers from 1 to n-1. …

Total answers: 2

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

"cryptography is required for sha256_password or caching_sha2_password"

"cryptography is required for sha256_password or caching_sha2_password" Question: Good day. Hope your all are well. Can someone help me with fix this? I’m new to the MySQL environment. I’m trying to connect to MySQL Database remotely. I used the following python code and got this error. Print(e) = “cryptography is required for sha256_password or caching_sha2_password” …

Total answers: 12

DES cipher with pyca/cryptography (PBEWithMD5AndDES)

DES cipher with pyca/cryptography (PBEWithMD5AndDES) Question: To support some legacy application I need to implement PBEWithMD5AndDES (RFC2898 Section 6.1) in python. I know this is insecure, deprecated and should not be used anymore. But this is sadly the requirement I have. I already have a working version that uses PyCrypto/PyCryptodome but I would need to …

Total answers: 2

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

How to unpad PKCS#7 / PKCS#5 padding?

How to unpad PKCS#7 / PKCS#5 padding? Question: I would like to for help with using the cryptography.hazmat.primitives.padding.PKCS7 Python class. After decryption I’m getting the string 453947000000197708080808, when the plaintext should be 4539470000001977. According to our development team, the plaintext should be padded with PKCS#5 padding. So I searched for this class, but could not …

Total answers: 1

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

How to encrypt text with a password in python?

How to encrypt text with a password in python? Question: Surprisingly difficult to find a straight answer to this on Google. I’m wanting to collect a piece of text and a message from a user such as 1PWP7a6xgoYx81VZocrDr5okEEcnqKkyDc hello world. Then I want to be able to encrypt/decrypt the message with the text somehow so …

Total answers: 6

Python: where is random.random() seeded?

Python: where is random.random() seeded? Question: Say I have some python code: import random r=random.random() Where is the value of r seeded from in general? And what if my OS has no random, then where is it seeded? Why isn’t this recommended for cryptography? Is there some way to know what the random number is? …

Total answers: 1