Masterlock SpeedDial Padlock Review

image

I saw this lock at Walmart for $8 and couldn’t resist, since its so different than regular combination locks. 

Operation

Operating the lock is amazingly simple and elegant.  Rather than rotating the dial like a traditional lock you push it in the cardinal directions.  This has two big benefits.  Firstly it requires much less dexterity to use then a traditional combination since you only have the be able to push the lock in 4 directions rather than be able to rotate the lock to 39 different angles.  Secondly it allows you to enter even fairly long combinations in under 10 seconds.  The lock is also user settable to any combination you want, in less than 30 seconds.  (Assuming you don’t choose a 37 move combo or something)

How it works

The internals of the lock are truly clever.  I won’t bother going over them since there is this nice pdf that already does that.  And there is this great flash visualizer that shows you how the internals of the lock work in operation.

Security

Because of the way the lock works there are only 7,501 states the internal mechanism can be in.   So although there are lots, 4^8, combinations of length 8 all of them map to one of the 7,501 states.  More troubling however is that a combination of length 8 may produced a state that is the same as a combination of length 4.  The table below summarizes the probable ‘badness’ of combos of different lengths.  It shows that combos of length 7 seem to be the sweet spot.

Number Of moves Combos Unique lock states not produced by smaller combos % Bad Combos* Bad Combos*
11 4194304 104 2.35% 98652
10 1048576 708 1.97% 20692
9 262144 1796 1.38% 3608
8 65536 1984 0.68% 448
7 16384 1448 0.34% 56
6 4096 816 2.64% 108
5 1024 396 29.69% 304

*Bad combos mean a combination that can be open by another combination shorter than 5 moves.

Since all the combinations of length 4 or less can be tried in about 20 minutes, 249*5sec, having a combination that can be open with a combination of 4 or less opens you up to a brute force attack.  Unfortunately these bad combos are not simple to recognize as such.  For instance the combo up,up,right,up,down,down,left,right is the same as right,right,right,right. 

Conclusion

Although there is a small chance, that you can accidently pick a bad combination for the advertised purpose of protecting a high school locker it should be more than adequate security and the easy of use is much better than a traditional lock.

Yay! PNGOUT – How to install on Dreamhost

PNGOUT is a wonderful little utility written by …. (of Duke Nukem fame) that compresses PNG files by about 15%-20% on average.  Which if you have many PNG images in you website can make a small but noticeable difference in load times.  Although there are other similar utilities PNGOUT seems to be regarded as the best so I decided to use it.  Since I already had a lot of images I wanted to compress on this blog I had to figure out a couple of things to easily compress them.

  1. I wanted to run PNGOUT on my webhost server since then I wouldn’t have to transfer the files back and forth to compress them.  Since Dreamhost has linux servers so that required finding a linux port of PNGOUT.  As and added benefit this should make it reasonably simple to make a cron job to compress all PNG images later.
  2. I wanted to basically make it a one line command to compress all my PNG files so I had to figure out how to find all PNG images under a directory and run PNGOUT on them

Nothing particularly complex so lets dive in.  Step one was easy as there is already a well know port of PNGOUT available although it took a bit of searching to find the download site.  Now I just download the Linux  Dynamic zip, unzip it and load up the i386 executable to my home directory on my webhost. (Make sure to make it executable)

After testing to make sure pngout worked on a single file I set about finding how to do it on all PNG files under a directory.  Give that I am not a linux expert it was pretty easy as the find command let me do everything I wanted.

find blog_directory -name *.png -exec ./pngout {} \;

That will find anything under blog_directory that matches the naming pattern *.png and run pngout on it.  That was easy enough I may actual setup a cron job sometime.

Where Ultra@VNC store its ‘host’ list

Short answer

HKCU\Software\ORL\VNCviewer\MRU

Long answer

In UltraVNC it keeps a list of the host you connected to before in its little drop down.

image

Over time it tends get cluttered with one time use entries making it more difficult to pick the right one.  After it became enough of a burden I opened up Process Monitor to see what I could see.

image

After dialing in the filtering so I was only looking at vncviewer.exe I can see its writing to the registry in a directory called setting – that sounds promising.  Opening that up and routing around a bit reveals this.

image

Which looks suspiciously like the dropdown.  Basically you have some name/value pairs for the host names.   And index specifces their order.  And you can just delete any entries you want provided you also remove it from index.

And now I can sit back and enjoy my clutter free pull down.

I love DataTemplates

I have been playing around with WPF and  started writing a little game to experiment with.   So far I think my favorite thing about WPF has been data templates.  I defined a data template for a Gem Card, one of the game pieces.

<DataTemplate DataType="{x:Type game:GemCard}">
    <Border Style="{DynamicResource CardBorder}" Background="Green">
    <Border Style="{DynamicResource CardHighlight}">
        <Grid>
            <Label Content="{Binding Value}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="5" FontSize="18.667"/>
            <Label Content="{Binding Value}" HorizontalAlignment="Right" VerticalAlignment="Bottom" Margin="5" FontSize="18.667"/>
            <Path Stretch="Fill" Stroke="Black" Data="m0,0 l1,1 -1,1 -1,-1z" Fill="Red" HorizontalAlignment="Center" VerticalAlignment="Center" Width="40" Height="60"/>
            <Label Content="{Binding Gems}" FontSize="18.667" HorizontalAlignment="Center" VerticalAlignment="Center"/>
        </Grid>
    </Border>
    </Border>
</DataTemplate>

And when I put a GemCard in a content control in my game it looks something like this

image

I like this approach a lot because I can just tell WPF how I want my classes to be presented and then I can just start putting them in listboxes with out having to worry about how the will look.

List.Pop

I started writing a little WPF card game and kept coming up against having to remove and store an item from the list – essentially a pop operation.  So I wrote the following extension method.

public static class ListPopper
{
    public static T Pop<T>(this IList<T> list)
    {
        T value = list.FirstOrDefault();

        list.Remove(value);

        return value;
    }
}

I eventually decided to switch to a Stack for the card game – but I think the extension method may come in handy for other projects.