Archive

Archive for July, 2010

My Lotus Domino Development Experiences

July 2, 2010 2 comments

Lotus
I’ve been doing lot of coding in Lotusscript recently. When I started Lotus development I didn’t like the language, platform, environment and the technology at all.

Now I feel that there were lot of reasons for that kind of thought at that time. At that time I was completely fascinated by JavaScript and various related technologies and want to spend my complete time on it. Still I love JavaScript and the front-end development (I miss it greatly) and trying to spend some time personally with the front-end part of the development.

But now I think I have started to like Lotus development even the platform can be unpredictable at times. There can be things that you’ll never get an explanation, which is completely out of our logic. But once you learn avoid these kind of things and move forward everything will be fine (from my experience).

I wouldn’t have liked this technology without the help of my colleague Denis. He is like a Lotus encyclopedia that can be explored whenever I stuck with something. Be it administration issue, programming issue, connection issues he was there for the help.

I am thinking about a day in which I’ll love the Lotus domino rather than like it. Hope the day will come soon.

Categories: General

JavaScript Password Generator

Yesterday one of my friend contacted me for a simple JavaScript password generator that he wants to use in their Intranet.

Like everyone I thought of depending on Google, but after hearing his requirements I thought of making one myself. The code may seem bit specific as I’ve done this for a very specific requirement.

function generatePassword(type, plen){
	var lwrAlph = "abcdefghijklmnopqrstuvwxyz",
		uprAlph = "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
		nums = "0123456789",
		spl = "~!@#$%^&*()-_=+|<>,.;:[]{}",
		passwd = [],
		maxLen = 32,		
		defLen = 8,
		minLen = 5;		

	/*Parameter Manipulations*/
	type = type || "all";
	type = isNaN(type)?type.toLowerCase():"all";	
	plen = plen || defLen;
	plen = (plen < 0?defLen:(plen <= maxLen? (plen < minLen?defLen:plen): maxLen));
	
	/*Choosing the password source characters*/	
	src = type === "alpha"? [lwrAlph, uprAlph]:type === "alphanum"?[lwrAlph, uprAlph, nums]:[lwrAlph, uprAlph, nums, spl];
	
	/*Password construction*/	    
    for (var i = 0; i < plen; i++) {
        var rnd = Math.floor(Math.random() * src.length),
			charBuild = src[rnd].split("");		     
        rnd = Math.floor(Math.random() * charBuild.length);
        passwd.push(charBuild[rnd]);
    }
    
    return passwd.join("");
}

The function accepts two parameters. The first one denotes type, which tells the routine what kind of characters should be used. This parameter can have 3 possible values: all, alpha and alphanum.

If you use value all the generated password can use alaphabets (lower & upper), numbers and special characters.

If you use alpha the generated password can use alaphabets (lower & upper).

If you use alphanum the generated password can use alaphabets (lower & upper) and numbers.

The second parameter denotes the length of the password going to generate. It has a restriction of 32 characters maximum and 5 characters minimum. If the user do not specify the length the a length would be selected by the code, which is 8. So it might be bit confusing at first but it is straight one once you check the logic.

I have furnished some test function calls that I’ve done earlier during a small testing period.

console.log(generatePassword("", -1));
console.log(generatePassword(""));
console.log(generatePassword());
console.log(generatePassword(null, null));
console.log(generatePassword(undefined, undefined));
console.log(generatePassword("alpha", 8));
console.log(generatePassword("alphanum", 8));
console.log(generatePassword("alphanum", 33));
console.log(generatePassword(-1));
console.log(generatePassword(1));
console.log(generatePassword("alphanum", 3));

I was using my Firebug console for checking the outputs of the function.

Follow

Get every new post delivered to your Inbox.