Getting md5
Posted: 2008-04-01T15:35:13+05:30

Want to get MD5 ? Examples are in Python and Java

In Python: >>> import md5 >>> print md5.md5(“kushal”).hexdigest() ‘6ec44a1207a3d9506418c034679087b6’ Easy isn’t it !!

Now let us do the same in JAVA:

import java.security.MessageDigest;
import java.lang.String;

class MD5 { public static void main(String args[]) { try { MessageDigest digest = MessageDigest.getInstance(“MD5”); digest.update(“kushal”.getBytes()); System.out.println(byteArrayToHexString(digest.digest())); } catch (Exception e){ e.printStackTrace(); } }

public static String byteArrayToHexString(byte in[]) {
    byte ch = 0x00;
    int i = 0; 
    if (in == null || in.length <= 0)
        return null;
    String pseudo[] = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "a", "b", "c", "d", "e", "f"};
    StringBuffer out = new StringBuffer(in.length * 2);

    while (i < in.length) {
        ch = (byte) (in[i] & 0xF0); 
        ch = (byte) (ch >>> 4);
        ch = (byte) (ch & 0x0F);    
        out.append(pseudo[ (int) ch]); 
        ch = (byte) (in[i] & 0x0F); 
        out.append(pseudo[ (int) ch]); 
        i++;
    }
    String rslt = new String(out);
    return rslt;
}    

}

I found that code on byteArrayToHexString somewhere in the net.

Update: As ignacio pointed in the comments that the md5 module is deprecated in Python 2.5, we have to use hashlib module instead. >>> import hashlib >>> h = hashlib.md5() >>> h.update(‘kushal’) >>> h.hexdigest() ‘6ec44a1207a3d9506418c034679087b6’

Comments

A nice article for the students who want to move from the blue world of "T****C" to GCC using KDevelop
Posted: 2008-01-18T12:25:27+05:30

Here is a nice tutorial for the beginners who wants to move to GCC/Free Software world using KDevelop. The KDevelop-Project was founded in 1998 to build up an easy to use IDE (Integrated Development Environment) for KDE. You can write in C/C++/Java/Qt/Python and many other languages in it. At the end of the tutorial , there is a nice shortcut table for KDevelop.

Comments

Shell scripts and me
Posted: 2007-05-01T17:24:45+05:30

I always feared shell scripts when I was in college. Always knew that it is very powerful if I use it properly, I never did.

Two days back, in I was trying to help one of my college junior to setup Qt4 and the environment to run it. I told him to follow this page. But Pradeepto said the idea of having another user is not so good. and he said:

Apr 30 00:48:21 pradeepto: you can even do make sure that as you changedirectories,
the env-vars are set automagically.
So, I tried to something like that, asked few questions on #bash about how to write a function with same name of a shell command and then call the actual shell command. So, got the shell-builtin-command ‘builtin’ which executes other shell builtins. Also asked lots of questions to Jace about shell programming :p

My target was, as I change my directory to any directory named ‘pyqt4’ or sub-directories under it all environment variables should change accordingly to run Qt4 or PyQt4 codes and in other directories the normal environment should stay to run Qt3 :)

The result in my .bashrc :

export tQTDIR=“$QTDIR”

export tPATH=“$PATH”

export tMANPATH=“$MANPATH”

export tLD_LIBRARY_PATH=“$LD_LIBRARY_PATH”

export tPKG_CONFIG_PATH=“$PKG_CONFIG_PATH”

export tQTINC=“$QTINC”

export tQTLIB=“$QTLIB”

export eFlag=0changePath()

changePath()
{QTDIR=“$tQTDIR”

PATH=“$tPATH”

MANPATH=“$tMANPATH”

LD_LIBRARY_PATH=“$tLD_LIBRARY_PATH”

PKG_CONFIG_PATH=“$tPKG_CONFIG_PATH”

QTLIB=“$tQTLIB”

QTINC=“$tQTINC”

export QTDIR PATH MANPATH LD_LIBRARY_PATH PKG_CONFIG_PATH QTINC QTLIB

}

cd ()

{

if [ “$#” -eq “0” ]

then

if [ “$eFlag” -eq “1” ]

then

changePath

export eFlag=0

fi

builtin cd

else

bname=echo "$1"|grep pyqt4

if [ “${bname}” = “$1” ]

then

QTDIR=/home/kdedev/src/kde/qt-copy

PATH=$QTDIR/bin:$PATH

MANPATH=$QTDIR/doc/man:$MANPATH

LD_LIBRARY_PATH=$QTDIR/lib:$LD_LIBRARY_PATH

PKG_CONFIG_PATH=$QTDIR/lib/pkgconfig:$PKG_CONFIG_PATH

QTINC=$QTDIR/include

QTLIB=$QTDIR/lib

export QTDIR PATH MANPATH LD_LIBRARY_PATH PKG_CONFIG_PATH QTINC QTLIB

export eFlag=1

builtin cd “$1”

else

if [ “$1” = “..” ]

then

builtin cd “$1”

dname=pwd

bname=echo "$dname"|grep pyqt4

if [ “$bname” != “$dname” ]

then

if [ “$eFlag” -eq “1” ]

then

changePath

export eFlag=0

fi

fi

else

if [ “$eFlag” -eq “1” ]

then

changePath

export eFlag=0

fi

builtin cd “$1”

fi

fi

fi

}

I think the code is not so much readable in my blog :)

Update: Pradeepto asked me to upload the code as a file, so here it is. Just copy paste the contents of this file into your $HOME/.bashrc .

Comments

D-link AirPlus DWl-G630 in Fedora Core 6
Posted: 2007-04-18T15:13:15+05:30

Last night bought a D-link AirPlus DWl-G630. After compiling & installing the driver, it is working :)

You can read the tutorial here. The lspci output is:

06:00.0 Network controller: RaLink RT2561/RT61 rev B 802.11g

Comments

Shell commands tutorial using Konsole part 1
Posted: 2007-04-14T16:27:42+05:30

Shell commands tutorial using Konsole, part 1 in bengali is out. You can check it out from here.

Comments

A Desktop tutorial
Posted: 2007-04-11T21:40:22+05:30

A basic tutorial on KDE desktop in a Fedora Core 6 box. You can download the Bengali or the English video.

Comments

KHangMan Tutorial
Posted: 2007-04-09T09:06:03+05:30

KHangMan is a part of the Edutainment group of KDE and is the computer port of the classical hangman game. You can download the bengali tutorial from here.

Tonight, the English version of the tutorial will come out :)

Comments

Kalzium tutorial
Posted: 2007-04-06T09:19:35+05:30

After two days of work , Kalzium tutorial in Bengali is ready. You can download it from here. Yesterday night, I gave more than 25 takes on this, either sound is not coming properly, or some problem in mixing. I need a good app which can help me in the process of dubbing the tutorials. The video is in ogg theora format, audio can I get in any format. Can anyone please point me to some good app?

Recordmydesktop is rocking as far as the video is concerned, but the sound mixing is not working properly.

Comments

KPercentage tutorial
Posted: 2007-04-03T22:57:44+05:30

My second video tutorial, this one is on KPercentage . You can download it from here (ogg format). Made some mistake in selecting the proper screen section.

Language: Bengali

Size: 4.7 MB

Comments

KBruch tutorial
Posted: 2007-04-03T09:44:46+05:30

Writing is always a difficult task for me. So, after I learned about Podcasting from Kiruba , thought of giving it a try. My last post was that test only Now another test, a tutorial of KBruch using screencasting with my bengali voice. Failed few times to speak proper bengali, but that problem will go out in the coming ones.The result on youtube.

You can also download it from here (ogg) or check it in google video.

Many people laughed on my first test, they will on this also. But I don’t have any problem, you guys should have some moments to laugh in your busy life.

Comments

Contents © 2004-2014 Kushal Das - Powered by Shonku