pycryptodome

Python AES encryption shows different result from originating C# code

Python AES encryption shows different result from originating C# code Question: The below code is my C# code for encryption using System; using System.IO; using System.Text; using System.Security.Cryptography; public static string Encrypt(string value) { byte[] bytes = Encoding.Unicode.GetBytes(value); Aes aes = Aes.Create(); Rfc2898DeriveBytes rfc2898DeriveBytes = new Rfc2898DeriveBytes("aaaabbbbccccddddffffeeee", new byte[13] { 73, 118, 97, 110, 32, …

Total answers: 1

Use key as byte array for DES3 in python

Use key as byte array for DES3 in python Question: I have a key and IV for DES3 as byte array (generated by C#): var _algo = TripleDES.Create(); _algo.GenerateIV(); _algo.GenerateKey(); Console.WriteLine(string.Join(", ", _algo.IV)); Console.WriteLine(string.Join(", ", _algo.Key)); I get these values for example: [220, 138, 91, 56, 76, 81, 217, 70] [88, 221, 70, 78, 149, …

Total answers: 1

Pycryptodome incorrect decryption

Pycryptodome incorrect decryption Question: I am generating a RSA key pair in a django view, storing the keys in db, sending the public key to the client template, encrypting a message, then sending the message to a different view where I am retrieving the private key from the db and trying to decrypt the message. …

Total answers: 1

AES encryptions/decryptions differs between Python and C#?

AES encryptions/decryptions differs between Python and C#? Question: i am using AES encryption/decryption in Python3 using the pip pycryptodome package on Linux (Debian, ubuntu). now i needed to implement the same program for Windows by using C#. but the encryption results differs between the two platforms (slightly). AES encryptions from Python (Linux) cannot decrypted on …

Total answers: 2

Python Incorrect AES key length despite passing the a 32 bytes bytearray

Python Incorrect AES key length despite passing the a 32 bytes bytearray Question: I have a specific AES key that I have to work with which is 11h,FFh,E4h,"I",BCh,D4h,96h,"SRZ",BEh,B2h,BEh,D0h,89h,E6h,EBh,91h,92h,"f",FCh,"#",BBh,F8h,"hn",8Dh,"Y",19h,"g",8Ah,"Q" I have to use this key to encrypt a message. In python I covert it to "x11,xFF,xE4,I,xBC,xD4,x96,SRZ,xBE,xB2,xBE,xD0,x89,xE6,xEB,x91,x92,f,xFC,#,xBB,xF8,hn,x8D,Y,x19,g,x8A,Q" but I get ValueError: Incorrect AES key length (60 bytes). …

Total answers: 1

ValueError: MAC check failed when using PyCryptodome to decrypt data coming from NiFi

ValueError: MAC check failed when using PyCryptodome to decrypt data coming from NiFi Question: Can someone help me with this problem: I am encrypting a JSON in NiFi with AES_GCM algorithm and using a KDF PBKDF2. The idea is to decrypt this JSON with a python script using PyCryptodome. The following code is an attempt …

Total answers: 1

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

Python import of ECC private key in PEM encoding fails

Python import of ECC private key in PEM encoding fails Question: I’m running Python version 3.8.2 and using pycryptodome version 3.9.9 to import an ECC private key in PEM encoding for later signing some data. The following EC private key is a sample key, and I’m using it for several cross-platform projects [e.g. Java, PHP, …

Total answers: 2