SHA1/MD5 Hash Libraries for LotusScript

Jason Molzen contacted me this weekend asking for help generating MD5 hashes in LotusScript. I had previously posted a HMAC SHA1 library that was an amalgamation of two developers’ (Paul Johnston and Julian Robichaux) code. Paul did not mind me converting the SHA1 code so I spent a lot of time translating the MD5 script he created.

With Jason’s help I converted Paul Johnston’s MD5 script but I wasn’t quite happy when I finished the library. The code was written as functions and it was hard to figure out what to use to create each hash.

I finally ended up with three script libraries. Click on the links to download the “lss” library files.

  • CoreHashLibrary - Contains one class called HashHelper (I loved using the word “Hash”). It contains a lot of the binary functions for processing these hashes.
  • MD5 - Self explanatory. This contains two classes: a MD5 class with a New(text) constructor and a HMAC_MD5 class with a New(key,text) constructor
  • SHA1 - Self explanatory. This contains two classes: a SHA1 class with a New(text) constructor and a HMAC_SHA1 class with a New(key,text) constructor

Jason sent a link to a great tool for testing these hashes: HashCalc. Previously, I had been testing the hashes with Paul Johnston’s javascript but HashCalc saved me a lot of time.

22 July 2008 | lotus, lotus notes, programming | No Comments

Sprint/Centro Update 1.07

Sprint and Palm published a new update for the Centro today. Release 1.07 updates the Centro’s ability to use Location based services in Google Maps.

Get the update here.

22 July 2008 | general | No Comments

Sugar Free Vanilla Iced Coffee @ McDonalds

I made the mistake of ordering a Sugar Free Vanilla Iced Coffee at McDonalds. It’s not worth the 200 calories saved. Go with the regular Vanilla flavoring.

22 July 2008 | general | 1 Comment

My COM Library Problem fixed

My goodness. I wasted a good portion of the week trying to get a C# COM/dll to work with Domino 8.

To summarize my problem… A COM dll that was working in R6.5 stopped working when we upgraded the server to R8. The dll was having issues finding the namgr.exe.config file that it used on the R6.5 install.

Solution: You won’t believe this… I spent a week recompiling the dll with different hard-coded values and different debug statements trying to figure out why it could not find that namgr.exe.config file. Luckily, I discovered a C# property that displays the expected configuration file path:

AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

A debug line showed that for some reason, Domino 8 expects a COM’s configuration path to be (programfile).config instead of (programfile).exe.config (e.g. namgr.config vs namgr.exe.config). I didn’t know Domino had any control over how .NET behaved but I have no other explanation for what happened.

Oh well… what seemed like a really easy fix took almost a week to discover.

14 July 2008 | lotus, lotus notes | No Comments

Multiple Forms in Domino Web Applications

I’m having some fun in a legacy application at work. The Lotus Notes/Domino forms I am creating and maintaining are embedded into an ActiveX frame (like a portal).

Prior to this application, I think all of my development has been under the assumption that my HTML form was the only form. Hence, document.forms[0] was my standard. Well, now that I’m working in this embedded application, that isn’t always true. I’ve had to rewrite some of my javascript to work with the current form.

Here’s a few of my current nuggets.

The first thing I had to create was a function to get the current form.

function getMyForm(field) {
// returns form element
	if (typeof(field) == "string") {
		for (var i = 0; i < document.forms.length;i++) {
			if (document.forms[i][field] != null) {
				return document.forms[i];
			}
		}
	} else {
		var element = field;
		while (element != null) {
			element = element.parentElement;
			if (element.tagName == "FORM") {
				return element;
				break;
			}

		}
	}

}

I am still debating how to implement the next function. I wasn’t sure if I should pass the form into the function, expect that I already have it (bad design), or get it using the function above. I actually do a mixture of the last two options. I typicall set a global form variable in the JSHeader but check for it in case it is not there.

function getFieldValues(field) {
// Returns array of values. Depends on getMyForm.
	var value = new Array;
	if (form == null || form.tagName != "FORM") {
		var form = getMyForm(field);
	}
	if (typeof(field) == "string") {
		var theField = form[field];
	} else {
		var theField = form[field.name];
	}

	if (theField.length == null && theField.options == null) {
		value =  [theField.value];
	} else if (theField.options != null) {
		for (var i = 0; i < theField.options.length;i++) {
			if (theField.options[i].selected == true) {
				value.push(theField.options[i].text);
			}
		}
	} else if (theField.length >= 0) {
		for (var i = 0; i < theField.length;i++) {
			if (theField[i].checked == true) {
				value.push(theField[i].value);
			}
		}
	} else {
		value = [''];
	}
	return value;
}

This is nothing new for a lot of developers and frameworks like jQuery and Prototype handle a lot of this. But in many instances, you’re stuck in legacy code that doesn’t allow you to throw in frameworks (or you really don’t want to have to explain what you’re doing to the other developers).

9 July 2008 | lotus, web design | No Comments

Being a Good Developer …

Damir Tomicic - Being a good developer is 3% talent, 97% not being distracted by the internet.

(via .NET Buzz Forum)

7 July 2008 | general | No Comments