Python Barcode Decoding on Non-Python Created Thread

Dynamsoft Barcode Reader 7.0 brings a set of thread-based APIs for continuous frame management and corresponding barcode decoding. It extremely simplifies the programming complexity, especially for Python. It is known that Python’s GIL (Global Interpreter Lock) affects the performance in a multi-threaded scenario. Running computation intensive tasks in Python thread cannot improve the Python app performance. If you create a Python barcode scanner app with OpenCV and Dynamsoft Barcode Reader 6.x, Python multiprocessing is the only way for getting a high camera frame rate. With the thread-based APIs of Dynamsoft Barcode Reader 7.x, your Python apps will not be limited by GIL anymore. This tutorial shares how to integrate the thread-based C/C++ APIs into Python barcode extension.

Read more

How to Use OpenSSL to Generate RSA Keys in C/C++

It is known that RSA is a cryptosystem which is used for the security of data transmission. This tutorial introduces how to use RSA to generate a pair of public and private keys on Windows.

  1. Download and install OpenSSL https://www.openssl.org/community/binaries.html.
  2. Find libeay32.lib, ssleay32.lib and libeay32.dll.
  3. The following sample code will generate a public key “public.pem” and a private key “private.pem”.
#include <stdio.h>
#include <openssl/rsa.h>
#include <openssl/pem.h>

bool generate_key()
{
	int				ret = 0;
	RSA				*r = NULL;
	BIGNUM			*bne = NULL;
	BIO				*bp_public = NULL, *bp_private = NULL;

	int				bits = 2048;
	unsigned long	e = RSA_F4;

	// 1. generate rsa key
	bne = BN_new();
	ret = BN_set_word(bne,e);
	if(ret != 1){
		goto free_all;
	}

	r = RSA_new();
	ret = RSA_generate_key_ex(r, bits, bne, NULL);
	if(ret != 1){
		goto free_all;
	}

	// 2. save public key
	bp_public = BIO_new_file("public.pem", "w+");
	ret = PEM_write_bio_RSAPublicKey(bp_public, r);
	if(ret != 1){
		goto free_all;
	}

	// 3. save private key
	bp_private = BIO_new_file("private.pem", "w+");
	ret = PEM_write_bio_RSAPrivateKey(bp_private, r, NULL, NULL, 0, NULL, NULL);

	// 4. free
free_all:

	BIO_free_all(bp_public);
	BIO_free_all(bp_private);
	RSA_free(r);
	BN_free(bne);

	return (ret == 1);
}

int main(int argc, char* argv[]) 
{
	generate_key();
        return 0;
}

You can feel free to download the sample code, and run it in Visual Studio.