c++

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

CRC computation port from C to Python

CRC computation port from C to Python Question: I need to convert the following CRC computation algorithm to Python: #include <stdio.h> unsigned int Crc32Table[256]; unsigned int crc32jam(const unsigned char *Block, unsigned int uSize) { unsigned int x = -1; //initial value unsigned int c = 0; while (c < uSize) { x = ((x >> …

Total answers: 2

Combining two non-pure CRC values

Combining two non-pure CRC values Question: Based on this answer I understand principle behind combining CRC values of two blocks, given the fact that CRC of string of zeros is 0 and using linearity property. But in practice most implementations seed the register with some initial value and complement the final result to deal with …

Total answers: 1

A memory leak in a simple Python C-extension

A memory leak in a simple Python C-extension Question: I have some code similar to the one below. That code leaks, and I don’t know why. The thing that leaks is a simple creation of a Python class’ instance inside a C code. The function I use to check the leak is create_n_times that’s defined …

Total answers: 1

Python code doesn't work like it does in C++

Python code doesn't work like it does in C++ Question: How to get the same values ​​in Python as in C++? CPP code #include <bitset> #include <iostream> using namespace std; int main() { short int divider = -32768; auto divider_bin_str = bitset<16>(divider).to_string(); cout << "divider: " << divider << " " << divider_bin_str << endl; …

Total answers: 1

Algorithm formation in c language

Algorithm formation in c language Question: SO i am trying to make a algo that shift element in array when ever 2 is found in array input 3 4 2 9, output 4 2 9 0 this output is needed , I have tried some sort of code but quite confused cause it either copys …

Total answers: 2

Use information from one argument to create another argument in typemap(in)

Use information from one argument to create another argument in typemap(in) Question: Currently I have the following C snippet: typedef struct My_Struct { int x; int y; } my_struct_t; void generate_buffer(my_struct_t info, uint8_t* buffer_out); I am trying to come up with a python swig interface to call this function. The output buffer size is in …

Total answers: 1

How to run sicpy.signal freqz in C# / ASP.NET Core?

How to run sicpy.signal freqz in C# / ASP.NET Core? Question: I need to run Python source code (.py) with dependencies on numpy and scipy.signal in the ASP.NET Core context. I’ve found IronPython to be a suitable solution, but it doesn’t support these two dependencies (GitHub issue #355). So, I decided to automatically generate C# …

Total answers: 1