Monday, November 08, 2010 at 12:06 AM.


on randomizeAllPasswords (adrInRoot) {
		<<5/1/10; 11:53:51 AM by DW
			<<Given an address in an object database, reset all objects named password or secretSubject to a random string of 10 characters. This makes it possible to ship websites with the user information intact, without revealing any passwords. The email addresses were already public, so nothing is revealed there that wasn't already available. 
	local (alist = string.parseaddress (adrInRoot), ct = 0, flmessages = true, ctrandomized = 0);
	on randomizePasswords (adrtable) {
		local (adr);
		for adr in adrtable {
			if (++ct % 100) == 0 {
				msg (ct + ": " + string.popFileFromAddress (adr))};
			if typeof (adr^) == tabletype {
				randomizePasswords (adr)}
			else {
				local (lowername = string.lower (nameof (adr^)));
				if (lowername == "password") or (lowername == "secretsubject") {
					adr^ = string.getrandompassword (10);
	randomizePasswords (@[alist [1]]);
	return (ctrandomized)};
bundle { //test code
	local (adrroot = @["Macintosh HD:Users:davewiner:Desktop:OPML:Guest Databases:www:docserver.root"]);
	dialog.alert (randomizeAllPasswords (adrroot) + " passwords randomized.")}

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.