I’ve had a Remington Shortcut for quite some time now but lately its been running out of juice after only a few minutes. The blades are in great shape so I thought maybe I could just replace the batteries. In the worst case I’d have fun taking it apart and in the best case I’d have a working shaver again.
One of the original batteries looked a bit corroded around a connector and in hindsight I think this was the main problem. I ended up replacing the generic cells with my favorite Eneloops anyway. Rechargeable and hardly any discharge even over a year of storage. Lovely lovely batteries.
I haven’t soldered in years (and it shows) but I had a lot of fun fixing the shaver. It works great now too. Actually, better. The recharging indicator is once again working and my small tweak to disable the edge clipper mechanism means less resistance on the motor.
Taking apart things to learn how they work is great fun. Sometimes you can even put them back together again.
One really important feature missing from Halogen eAppraisal is the ability for users to reset their own passwords.
Seems like such a basic feature but even their friendly support folks confirmed that there was no addon or plan to release the feature in a future version. Weird!
No matter though, let’s make our own.
Investigation
I spent untold amounts of time clawing through unfamiliar Java code. A occasional scrap was enough to forge my determination but nothing really made sense yet. Too many files, too many directories but maybe if I just kept trying…
Hidden deep within the lair of <Tomcat>\webapps\Halogen\WEB-INF\classes\com\halogensoftware\common\security\ is a file called ‘Utility.class’. Inside, a string that resembles the worst regular expression ever created.
I was sure this string was used to encrypt the passwords stored in the database but I needed a way to confirm that so…
Using a test account I set the password to the number 1 which was encrypted as the letter Y. Password 11 became Y}. Password 111 became Y}c.
Ah, so simple!
If your password was the ^ symbol it would find it in the string above and then move right one space and choose the letter “a” as your encrypted password. If your password was ^^ then the the first encrypted character would be “a” again but the second one would shift two places to the right and store the ` symbol
Here are a few more example conversions.
^^^ becomes a`Z
wT7w becomes (hi)
A+z becomes ^^^
Notice that in the last example we’ve simply looped around once we hit the right side of the hash string.
Now that we know how it works let’s build our own utility in ASP that we can use to reset anyone’s password.
The Solution
Besides the obvious DSN string, you’ll want to carefully consider how you validate your users.
The setup I used at work talked to a Human Resources database and would validate no less than three pieces of information before even attempting a reset. I urge you dear reader to do the same.
sID = Request.Form("id")
sPassword = Request.Form("password")
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open "DSN String for the Halogen eAppraisal Database"
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.Open "SELECT TOP 1 * FROM [view-user_info] WHERE username = '" & sID & "'", oConn, 0, 3 'adOpenForwardOnly, adLockOptimistic
If not oRS.EOF then
sKeyCode = "a`Z{b1Y}c2X[d3W]e4V|f5U\g6T:h7S;i8R""j9Q'k0P<l-O>m=N?n~M,o!L.p@K/q#Jr$Is%Ht^Gu&Fv*Ew(Dx)Cy_Bz+A"
sKeyCodeLength = Len(sKeyCode)
x = 1
sBadChar = 0
Do until x > Len(sPassword)
sChar = Mid(sPassword, x, 1)
If InStr(sKeyCode, sChar) then
sKeyCodePos = InStr(sKeyCode, sChar) + x
If sKeyCodePos > sKeyCodeLength then
'Need to loop around the beginning
Do until sKeyCodePos <= sKeyCodeLength
sKeyCodePos = sKeyCodePos - sKeyCodeLength
loop
End If
sEncodeChar = Mid(sKeyCode, sKeyCodePos, 1)
sEncodePassword = sEncodePassword + sEncodeChar
Else
'Could not find a character in sKeyCode
sBadChar = sBadChar + 1
End If
x = x + 1
loop
If sBadChar > 0 then
Response.Write "<p><strong>Unsupported characters were used to try to set the encrypted password. New password was not saved.</strong></p>"
Else
oRS("password") = sEncodePassword
oRS("password_change_date") = NULL
oRS.Update
Response.Write "<p>The password for your account " & sID & " has been reset.</p>"
End If
Else
Response.Write "<p><strong>A corresponding account for the user " & sID & " does not exist. Please contact support.</strong></p>"
End If
oRS.Close
oConn.Close
Set oRS = nothing
Set oConn = nothing
One of the neatest things about HTML5 is support for the new <audio> tag. Like <video> it allows you to natively support media in good browsers like Chrome, FireFox, Opera and Safari. Add a touch of JavaScript and a new era of media applications become possible.
Synthesizers, music trackers and games require seamless audio loops though so we need something a bit simpler for our first foray into HTML5 audio.
Oooh, how about a retro beatbox with individual track adjustments (start/stop/loop/volume) that could be used to build a unique soundscape from many separate instruments. Perfect!
Fantasy can only become reality through hard work so let’s get started with some tests first.
Tests were done on Windows 7 with Chrome 5.0.342.9 beta, FireFox 3.6.3, Internet Explorer 9.0 Preview, Opera 10.51 and Safari 4.0.5.
Chrome seems to trigger loops before the current sound is completely finished leading to some odd jumpiness. All loop methods are affected.
FireFox doesn’t seem to like the ‘loop’ property of method 1, odd. Method 2 has the slightest of delays between loops and method 3 was actually perfect! I didn’t believe it until verification at the millisecond level with Audacity. Hooray Mozilla!
Internet Explorer 9 doesn’t support the audio tag yet. Hopefully it will before an official release.
Opera performs almost as well as FireFox although there is still a small delay even when using method 3.
Safari seems slow to start playback which is very easy to detect once you hear a loop. All loop methods affected.
Feedback on other browsers/OS compatibility would be very interesting so please feel free to discuss any findings in the comments below.
Final Thoughts
As of right now (April 11, 2010) only FireFox can do a perfect loop by cheating a bit and using two <audio> elements with JavaScript.
So yeah, it’s a bit too early for HTML5 audio loops but don’t let that stop you from creating sound boards, media players and other fun things.
Hopefully with some more optimizations audio support will continue to improve and a HTML5 beatbox fantasy can become reality.
Until then there are plenty of other fun things to play with.