Base64 En-/Decoding using OpenSSL in C

IT, UNI Kommentare deaktiviert

Recently i had to implement Base64 en & decoding using openssl’s bio library, which by the way is just great, but a little “under-documented!”

If you ever wondered, why the standard example of decoding base64 data always returns 0 when using it with your test data? Well there is some nice undocumented feature: Strings that do not end with a newline ‘\n’ are not processed! So you have two possibilities: adding a newline to the string or use the following flag:

BIO_set_flags(BIO* to your bio_f_base64, BIO_FLAGS_BASE64_NO_NL);

Edit: 21/Dec/08:

After handin of the courses homework i can now give some details about how to do it:

Using a chain of BIO filters is the most flexible way to handle proper base64 en-/decoding:


//write base64 coded data to stdout
BIO* b64 = BIO_new(BIO_f_base64());
BIO* bio_out = BIO_new_fp(stdout, BIO_NOCLOSE);
bio_out = BIO_push(b64, bio_out); //attach output bio to base64 bio
BIO_write(bio_out,"data",sizeof("data"));
BIO_flush(bio_out); //flush the buffer
BIO_free_all(bio_out); //cleanup!

For more information see the super perfect documentation: http://www.openssl.org/docs/crypto/BIO_f_base64.html

Accessing Matlab from Java

IT Kommentare deaktiviert

Today i had to access a matlab script from a java program. After some hours of trying to get it work by using matlabs command line i found a method to call a matlab script without using the command line. Using matlab -r “functionName” didn’t work because of some unknown charset erros i haven’t found till now. The basic idea is based on this blog-post.

Therefore, a process must be created:


String command = "matlab -nosplash -nodesktop";
Process process = Runtime.getRuntime().exec(command);

Afterwards we obtain the standard-input of the process and send a command to be interpreted by matlab:


BufferedWriter out = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
out.write("function_to_be_executed");
out.write("\n");
out.write("exit;") // this will close matlab after the execution finished!

If you like to see what is happening, try to read from the process.getInputStream()

hope that helps some of you!

Taking a Webcam-Snapshot on Ubuntu/Dell Vostro 1510

Allgemein Kommentare deaktiviert

Today i got to take snapshots with the integrated camera of my Dell Vostro 1510!

After some tries using mplayer, gqcam, camstreamer and others, I thought it would never work. But some adjustment of the parameters passed to mplayer it finally worked to get out movies:

mencoder tv:// -tv driver=v4l2:device=/dev/video0 -ofps 60 -ovc lavc -lavcopts vcodec=mjpeg -o test.avi

To record single images use these commands:

mplayer -vo jpeg -fps30 tv:// -tv driver=v4l2:device=/dev/video0 -frames 1

The file 00000001.jpg now contains your screenshot!

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS