Monthly Archives: February 2007

Howto base64 decode with C/C++ and OpenSSL

Someone asked for an example of decoding with OpenSSL on the Howto base64 encode with C/C++ and OpenSSL post. So here it is:

#include <string.h>

#include <openssl/sha.h>
#include <openssl/hmac.h>
#include <openssl/evp.h>
#include <openssl/bio.h>
#include <openssl/buffer.h>

char *unbase64(unsigned char *input, int length);

int main(int argc, char **argv)
  char *output = unbase64("WU9ZTyEA\n\0", strlen("WU9ZTyEA\n\0"));
  printf("Unbase64: *%s*\n", output);

char *unbase64(unsigned char *input, int length)
  BIO *b64, *bmem;

  char *buffer = (char *)malloc(length);
  memset(buffer, 0, length);

  b64 = BIO_new(BIO_f_base64());
  bmem = BIO_new_mem_buf(input, length);
  bmem = BIO_push(b64, bmem);

  BIO_read(bmem, buffer, length);


  return buffer;

Tags: , ,


Recently it seems like the SOAP vs REST debate is heating up. Most of the debate seems to be leaning toward convincing people to not use SOAP based on its increasing complexity. Different people have different views on what REST is but in general if you look at the SOAP specifications or SOAP Standards and Web services and then look at the REST specification, REST for the Rest of Us, or REST you see that in general there is a lot more complexity to SOAP and that is just SOAP itself and not any of its extensions. Here are some good articles I've found that should give you insight into the debate:

After looking over the above references you may be interested in looking at Programmable Web's API list and see what others are using. The majority of the public services listed offer REST interfaces with some offering both REST and SOAP and very few offer just SOAP. Even though REST seems to be in favor now I believe there are still plenty of areas where SOAP makes sense when you have resources to devote to feeding and caring for it.

Tags: , ,

Acrobat Reader 7 and FC6

I broke down and wanted to install Adobe Acrobat Reader 7 on my FC6 box to replace xpdf. After installing it from the tar.gz version the acroread startup script bombed out with the error: expr substr 2400000000000 1

After a little searching I didn't find much help so I started looking at the script myself to see if I could track down the problem. It turns out that it wasn't that hard to fix. First off the script file was located at: /usr/bin/acroread

Open the script file and find the function named "check_gtk_ver_and_set_lib_path". This is the location of the first error you will hit. To fix the error you will need to change:

base_version=`expr substr "${base_version}0000000000" 1 $len_version`



You will find this two places and it needs to be changed in both. If you don't notice the 2nd place it is right after the first in a loop:

while [ $len_version -gt $len_base_version ]; do

The second problem you will have is located in the function "get_gtk_file_ver". Find this function and change the following line:

echo $mfile| sed 's/libgtk-x11-\([0-9]*\)\([0-9]\)00.\([0-9]*\)\|\(.*\)/\1\2\3/g'


echo $mfile| sed 's/libgtk-x11-\([0-9]*\)\([0-9]\)000.\([0-9]*\)\|\(.*\)/\1\2\3/g'

Now you should be able to run acroread without errors.

Tags: , ,

Dynamic DNS with EC2 and ZoneEdit

There seems to be a lot of questions on how to set up dyndns with EC2. It is fairly easy to do but I haven't seen anyone put everything together to do it yet so I figured I would write a little example using ZoneEdit. I picked ZoneEdit because it lets you sign up and host 5 domains for free.

First you need to sign up for a free ZoneEdit account and add your domain. I'll assume you can do this. Don't forget to change your domain to point to the ZoneEdit DNS servers.

Continue reading