Posts

Showing posts from December, 2010

The SQL Server and .Net equivalent of PHP and MySQL's SHA1 function

In PHP and MySql there is an sha1(str) function which generates an sha1 hash of a string. Their usages are simple: <?php echo sha1('password'); ?> //Outputs:5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 mysql> select sha1('password'); +------------------------------------------+ | sha1('password') | +------------------------------------------+ | 5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8 | +------------------------------------------+ 1 row in set (0.00 sec) Similarly, .Net has an SHA1 method within the System.Security.Cryptography  namespace which can be used in the following manner to generate the same hash. public static string Sha1(string hashStr, Encoding encoding) { var sha1 = new System.Security.Cryptography.SHA1CryptoServiceProvider(); var hash = sha1.ComputeHash(encoding.GetBytes(hashStr)); return BitConverter.ToString(hash).Replace("-", ""); } Console.WriteLine(S

Netbeans Native Linux GTK Look and Feel

Fedora updated my Netbeans install last night and I had to set the look and feel in the config file again. Since this happened a few times and I never remember the laf option I thought I would write it down. Especially since the default Netbeans look and feel seems very ugly to me. To change the laf to GTK add "--laf com.sun.java.swing.plaf.gtk.GTKLookAndFeel" to the netbeans_default_options in the netbeans.conf file. The netbeans.conf file is located in /usr/share/netbeans in the etc subdirectory of the netbeans version you are running.

Using Windows Powershell To Find A String Within Files

The below will find searchstr in all files with the .txt file extension in the current directory and all sub-directories and place the results in c:\tmp.txt Select-String searchstr $(dir . -recurse | where {$_.extension -eq ".txt"}) | out-file c:\tmp.txt