Saturday, January 29, 2011

libperseus 1.0.1 (python + java binding)

Hi !

We have updated libperseus library, and now you can use it with python (with ctypes) and java (with jni). The new stable version is now available.

So, if you would like to use Perseus technology, the first thing to do is to compile the library :
desnos@cvo:~/$ tar xvzf libperseus-1.0.1.tgz
desnos@cvo:~/$ cd libperseus-1.0.1
desnos@cvo:~/libperseus-1.0.1/$ make
To use Perseus with >= Python 2.5, you must have the shared library in your path and the perseus python module (see the "python" directory for examples) which encapsulate all stuff.

The first thing to do is to create a new Perseus object, with four float (0.0 to 1.0) numbers to generate noise (if you don't specify these numbers, the module will do it) :
from random import random
from perseus import Perseus

p = Perseus(aleas=[ random() for i in range(0,4) ])
and after you can code or decode your string with the code and decode methods of the Perseus object :
encoded_data = p.code( "CVO BLOGSPOT" )
decoded_data = p.decode( encoded_data )
About the java binding (see the "java" directory for examples) , we have written a class to use it more easily. But the first thing to do before is to compile it (you must edit the Makefile to setup the jni headers of your java installation : JAVA_INCLUDE) :
desnos@cvo:~/libperseus-1.0.1/java/$ make
Next you can create a Perseus object (as in the Python module, you can specify or not the noise numbers) into a new class file :
Perseus p = new Perseus();
And you can use Code and Decode methods of the object :
String data = new String( "CVO BLOGSPOT" );

String encoded_data = p.Code( data );
String decoded_data = p.Decode( encoded_data );
Easy, no ? ;)

Have fun !