Freelancer's Playground! Learn Programming, The Freelancer's Way

30Jan/070

Create Updatable Scroller Text

This tutorial came from a project of mine. At that time, someone ask me to create a scrolling text that updated when the data is modified. After look into the problem I found that this problem can be done using simple ajax and php script. This tutorial will show you how I completed this task.

Filed under: Tutorial Continue reading
26Jan/070

Creating Random Password in JAVA

Sometime, we need to create a random string for some purposes. Well, I do need this random string for a project of my friend. So, how do I create this random string? The idea is simple, I just need to create this random string from MD5 hashes that came from current time and multiply it by random integer and multiply again by some integer.

MD5 md5 = new MD5();
Date date = new Date();
long seed = date.getTime();
seed = seed * (1 + (int)(Math.random() * 5000));
md5.Update(String.valueOf(seed));
hash = md5.asHe<img src='http://bayu.freelancer.web.id/smilies/yahoo_angry.gif' alt='&#120;&#40;' class='wp-smiley' width='34' height='18' title='&#120;&#40;' />).toUpperCase();
int startIndex = 1 + (int)(Math.random() * 50);
if(((startIndex + passwordLength) - 1) &gt; hash.length()){
startIndex = hash.length() - passwordLength;
}
returnValue = hash.substring(startIndex - 1, (startIndex - 1) + passwordLength);

As For the MD5, I use a library from FastMD5. And this is my code. Well, it's a non optimized code. But, you should get the point.

Filed under: Tutorial Continue reading