The story of AES (Advanced Encryption Standard)

October 13, 2009 by mavl4219

Ever wanted to know how AES became AES, or how it works? This is the fun way to learn it.
Story of an AES, presented as a comic…great work. Complements to the author.

AES Story

AES Story

Freaky redirecting: …> /dev/null 2>&1

September 16, 2009 by mavl4219

I saw this (or similar) redirection many times (specially with g++’s output), but i have never bothered to search for explanation – until now.

First:
There are three standard outputs in *NIX environment STDIN (standarad input), STDOUT (standard output) and STDERR (stderror).
By default, STDOUT is used, and so a redirection in style … > /dev/null means, standard output is redirected to a black hole.

But what about 2>&1??

Well, standard I/O’s can be named with NUMBERS! And so, STDIN becomes 0, STDOUT becomes 1 and STDERR becomes 2.

So if you redirect 2>&1, this actually means: STDERR>&STDOUT. I guess & before 1 is needed to get a reference for STDOUT.

Example:
g++ test.c -o test > /dev/null 2>&1 means the following:
1. Redirect standard error to standard output
2. Redirect standard output to a black hole

Which means all output from an application is redirected to a black hole!
This is the easiest way to make the output from a compiler (or any other application) really quiet!

Run-time library linking

September 9, 2009 by mavl4219

This is not a new thing…but i’ve discovered it recently.

My project tree contains two libraries in libs/ dir, and whenever i try to compile in a new terminal, i have to setup the LD_LIBRARY_PATH…but not when using -Wl -rpath switches.

When compiling, just add -Wl,-rpath=/path/to/your/libs, and these are the paths, application will used at run-time.

Brief example:
g++ -o foo foo.c -L/usr/local/lib -lfoo -Wl,-rpath=/home/mylib/.libs

and, if you’re using Autotools, just add following text to _LDFLAGS.

Brief example:
myapp_LDFLAGS = @BOOST_LDFLAGS@ -L/usr/local/lib -Wl,-rpath=/home/mylib/.libs

There are some (minor) downfalls using this switches, but are not documented here…

P.S.: I’m using Ubuntu 8.10, kernel 2.6.27-7, g++ version is 4.3.2