cryptography

What's the chance of a collision in Python's secrets. compare_digest function?

What's the chance of a collision in Python's secrets. compare_digest function? Question: The closest function I can find to a constant time compare in Python’s standard library is secrets.compare_digest But it makes me wonder, if in the case of using it to verify a secret token: What’s the chance of a collision? As in, what’s …

Total answers: 1

Blinding a message with PyCrypto in Python 3+

Blinding a message with PyCrypto in Python 3+ Question: In Python 2, there were two methods called blind/unblind. Their docs recommend that you should now use pkcs1_15, however they only show how to sign/verify a message. Their sample code looks like this: from Crypto.Signature import pkcs1_15 from Crypto.Hash import SHA256 from Crypto.PublicKey import RSA # …

Total answers: 1

Python code for generating valid BIP-39 mnemonic words for a bitcoin wallet not working

Python code for generating valid BIP-39 mnemonic words for a bitcoin wallet not working Question: I am trying to generate valid BIP-39 mnemonic words for a bitcoin wallet in Python, but I am encountering an issue with the generated words being rejected by verification tools. I have followed the guidelines outlined in the BIP-39 standard, …

Total answers: 1

some problems of using Python's Cryptography on Windows

some problems of using Python's Cryptography on Windows Question: I would like to use the cryptography’s module on Windows, I am using version 1.12 and Python 3.10.6, and I have some problems. Actually, when I run my script, I receive the error : ` Traceback (most recent call last): File "C:/Users/edoua/Documents/cryptographie.py", line 1, in <module> …

Total answers: 1

reimplementing crypto-js in python cryptography

reimplementing crypto-js in python cryptography Question: I want to implement the following code (written in JavaScript, using the crypto-js library) in Python (using the cryptography package) const data = ‘base 64 encoded encrypted data’; const salt = ‘XB7sHH26Hn&FmPLxnjGccKTfPV(yk’; const pass = ‘.. password ..’; const psw = `${PBKDF2(pass, salt)}(tXntTbJFzh]4EuQVmjzM9GXHCth8`; let data = AES.decrypt(data, psw).toString(enc.Utf8); Here’s …

Total answers: 1

Web3 python crypto cypher issue on M1 Mac

Web3 python crypto cypher issue on M1 Mac Question: When I try to build a blockchain transaction using Web3 on python, I’m getting an error that is apparently because I’m using an Apple Silicon computer (2020 M1 MacBook Pro). I’m following a popular Solidity, Blockchain, and Smart Contract course on YouTube and I’m unable to …

Total answers: 2

Extract a public key from certificate

Extract a public key from certificate Question: I’m trying to extract a public key from my certificate but i keep getting this error: ValueError: RSA key format is not supported.. Below is my code: from Crypto.PublicKey import RSA bob_crt = ‘bob.crt’ public_key = RSA.import_key(bob_crt) if isinstance(public_key, RSA.RsaKey): print("RSA public key") else: print("Other key") —–BEGIN CERTIFICATE—– …

Total answers: 1