Welcome to Srini's blog

Thursday, January 13, 2011

Sankranthi Vacation 2011

Today I am going to my village to celebrate Sankranthi. To be frank I cann't njoy this trip much because of I am going for some purpose, My dream is in progress .... I need to give a hand to my family to go this op smoothly .... Don't think of other side.., new house buildng@village is in progress, So I need to address lots of issues to get some releif to my parents. I am proud to say that I am giving a nice gift to my parents in this new year, as they can live together there forever. I am sitting here and getting updates daily and arranging money on demand but my father really working hard there to get it run carefully/safely. Ohh ... sorry I am letting you bored .. forget about this .. Njoy the vacassion with your family ...make your family fills with happiness forever .. Wish you a very happy pongal ....



While surfing net I got an interesting cartoon about sankranthi .. please take look here ..Lol ...

Generate MD5 hash to a given string -- java

Yesterday I had a requirement to compute MD5 hash for a particular string to validate in my code. A quick googling I got lot of sources. Here I am posting the code which I worked out.

public class MD5Hash {
public static void main(String args[]) {
try {
String md5Hash = MD5("Give String");
System.out.println("MD5 hash is : " + md5Hash);
} catch(Exception e) {
//TODO: Nothing
}
}

private static String convertToHex(byte[] data) {
StringBuffer buf = new StringBuffer();
for (int i = 0; i < halfbyte =" (data[i]">>> 4) & 0x0F;
int two_halfs = 0;
do {
if ((0 <= halfbyte) && (halfbyte <= 9))
buf.append((char) ('0' + halfbyte));
else
buf.append((char) ('a' + (halfbyte - 10)));
halfbyte = data[i] & 0x0F;
} while(two_halfs++ < 1);
}
return buf.toString();
}

private static String MD5(String text) throws Exception {
MessageDigest md;
md = MessageDigest.getInstance("MD5");
byte[] md5hash = new byte[32];
md.update(text.getBytes("iso-8859-1"), 0, text.length());
md5hash = md.digest();
return convertToHex(md5hash);
}
}

Monday, January 10, 2011

Belated new year wishes

Belated new year wishes to all. Hope you all doing well. I had a fabulous night on Dec 31st, Loads with lots of lots of fun with frndz ... Recent days I am little bit busy with my personal as well as office works, thats why I didn't posted much posts. Now onwards I will keep on postings . May this new year fulfill your future gaols...

ur's
Srini .