Blogroll
- Smart Phone Arena - Helping Smartphone Users Worldwide
- Web Hosting
Random Word
Archives
- September 2008 (1)
- August 2008 (1)
- September 2007 (1)
- August 2007 (1)
- July 2007 (2)
- June 2007 (2)
- March 2007 (1)
- December 2006 (3)
- September 2006 (2)
- June 2006 (4)
- May 2006 (4)
- April 2006 (3)
As a few of you may know, it is pretty easy to encrypt plain text using MD5. It can be acheived just by calling the function md5(”plaintext”).
But when I recently started working on a Java-based web application, I realised that its not as easy to do it in JSP. So after a bit of research and looking around, I found a cool, simple solution to this problem. Here is the sample code which you can use in your JSP file or a Bean to do the encryption. (You need to import java.security.MessageDigest for this to work.)
String plainText = “root”;
MessageDigest md = MessageDigest.getInstance(”MD5″);
md.update(plainText.getBytes());
byte[] digest = md.digest();
StringBuffer hexString = new StringBuffer();
for (int i = 0; i < digest.length; i++) {
plainText = Integer.toHexString(0xFF & digest[i]);
if (plainText.length() < 2) {
plainText = “0″ + plainText;
}
hexString.append(plainText);
}
out.print(hexString.toString());
This can be a very effective way to encrypt passwords (after accepting them with the FORM POST method) before storing them in the database. Hope this little script will help atleast a few.
-Varma
about
Hello my name is Sunil varma. Welcome to my blog, and you're welcome to stay as long as you want.
categories
- Automobiles (1)
- General (9)
- Mobile (5)
- Programming (2)
- WordPress (1)
meta
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Sep | ||||||
| 1 | 2 | 3 | 4 | 5 | 6 | 7 |
| 8 | 9 | 10 | 11 | 12 | 13 | 14 |
| 15 | 16 | 17 | 18 | 19 | 20 | 21 |
| 22 | 23 | 24 | 25 | 26 | 27 | 28 |
| 29 | 30 | 31 | ||||
most commented posts
- » A New Forum Software On The Block! - 24
- » The Firefox Bus - 23
- » Implementing robots.txt File For A Forum Based Site - 8
- » Easy MD5 Encryption In JSP - 6
- » Discovery Channel Taught Thief How to Rob Houses! - 2
- » Pool ASR Theme v1.0 - 1
- » Basics for Generating Revenue from a Forum - 1
recent entries
recent comments
- enoch: A museum sponsoring time was favored and lined completely and this included constitutional nice legal agencies...
- nathaniel: Settle professional problems for any accretion or years. Fighters were then powered to delay in or...
- allegra 30mg: I’d like to confirm my reservation. ———— 8212;———&...
- asxaedcweferfgerf: amy beautiful blonde escort
- Duane: Take my comments off your blog. My safety is at risk.
Copyright ©2007, Varma's Blog

6 users responded to " Easy MD5 Encryption In JSP "
May 1 2008
its good… how can i decrypt it?
May 1 2008
reply me about the decryption
May 1 2008
MD5 is a one-way hash function, it cannot be decrypted.
February 17 2009
????? ?????? ???????? ?? ????????? ?? ???? ????? ?. ?????
????? ?????? “????????” ???, ??? ?????? ??????????? ? ???????? ???????? ?? ?? ??????? ??????????? ?????? ???????? ?????????????????? ?????? ?.?. ?????.
?????????????? ?? ?????? ??????, ? ????-?? “?????” ?????????? ??????? ?????? “?????????” ??? ?????, ??????? ???????? ???????? ? ????????????? ???? ????????? ??????????.
???????? “????????” ? ?????????? ??????? - ??? ????????, ??????? ??????? ???????? ?? ?????. ????? ???? ??????????? “?????? ???????” ? ???????? ???????????? ??? ????????????? ????????????, ????????????? ????????? ?????, ? ????, ???? ??????????? ???.
????? ??????? ?????????? ?????? ????????? 1 ????? ??????????-????????? ????? ? 9 ?????????? ?? ????????? ????????????? ???? ?????????? ??????? ?? ???????? ?????????? ????????????? ??????? ?.?. ???????.
? ??? ??? ? ?? ?????, ????? ????????? ??? ?????? ???????? ?????????????????? ??????? ? ??????????? ???? ?????????? ???????? ?????? ? ???????? ???????. ? ??? ????? ??????? ????????? ? ??????????? ????? “? ???????” - ?? ?????? 11 ????? ?????? ????????? ?????? 25 ? 35, ?? ????????? ??????? ????? ?????????????????? ?????? ????? ????? ????????? ?????????-????????????? ???????????? ???????????.
?????, ?? ?????????? ???????????? ???????????????? ??????? ?????????????????? ?????? ?? ??????????. ? ?? ??????? ???????????? ? ????????????? ??????????.
????? ????, ??? ?????????? ????????? ?? ? ?????????? ???????? ??????????, ? ????? ? ???????? ? ?????????? ???????????? ????????????????
March 23 2009
thanks a ton!!
December 23 2009
hey thanks a lot brother…

you made my day! merry christmas and happy new year! god bless u