Latest Snippets

Postback - showModalDialog

You'll notice if you do a postback/submit within a dialog window in IE, it posts...

General snippet posted by Christoff Truter on 2009-09-23 07:19:57
View Snippet

 

Set Maximum Request Size

In your web.config, find the system.web node and add the httpRuntime child node,...

ASP.net snippet posted by Christoff Truter on 2009-07-29 11:55:22
View Snippet

 

Force site to run in IE7 Compatibility mode

Recently we developed an intranet application simply using all the microsoft com...

General snippet posted by Christoff Truter on 2009-07-22 10:00:19
View Snippet

 

FileSystemWatcher example

An example of how to monitor the filesystem using the filesytemwatcher class in ...

C# snippet posted by Christoff Truter on 2009-06-27 22:08:12
View Snippet

 

Format Currency

Format a string into a currency format, similar to the FormatCurrency function i...

Javascript snippet posted by www.sonofsofaman.com on 2009-06-12 09:52:50
View Snippet

 

MD5 hash

The following snippet demonstrates how to create a MD5 hash using SQL 2005...

MSSQL snippet posted by Christoff Truter on 2009-06-11 10:01:37
View Snippet

 

Register Globals off

If you don't have access to your php.ini or the ability to set register_globals ...

PHP snippet posted by Christoff Truter on 2009-06-09 11:47:26
View Snippet

 

Table Variables

SQL 2000 introduced an alternative to temporary tables called table variables....

MSSQL snippet posted by Christoff Truter on 2009-06-08 15:59:55
View Snippet

 

MD5 hash

Calculate the MD5 hash of a given string...

C# snippet posted by Christoff Truter on 2009-06-02 14:08:47
View Snippet

 

Row Number

How to number rows of a query using mysql...

MySQL snippet posted by Christoff Truter on 2009-05-22 14:36:53
View Snippet

 

Snippets

MD5 hash

Calculate the MD5 hash of a given string

// Some namespaces needed
 
using System.Security.Cryptography;
using System.Text;
 
public string MD5(string input)
{
    MD5CryptoServiceProvider x = new MD5CryptoServiceProvider();
    byte[] bs = Encoding.UTF8.GetBytes(input);
    bs = x.ComputeHash(bs);
    StringBuilder s = new StringBuilder();
 
    foreach (byte b in bs)
    {
        s.Append(b.ToString("x2").ToLower());
    }
    return s.ToString();
}


posted by Christoff Truter on 2009-06-02 14:08:47

 

Comments

MD5CryptoServiceProvider x = new MD5CryptoServiceProvider();
byte[] bs = Encoding.UTF8.GetBytes(input);
bs = x.ComputeHash(bs);
StringBuilder s = new StringBuilder();
foreach (byte b in bs)
{
s.Append(b.ToString("x2").ToString());


comment posted by Anonymous on 2009-12-08 07:26:37

 

Alternative MD5

In the System.Web Namespace within the FormsAuthentication Class, there is
a static method called HashPasswordForStoringInConfigFile, where one can
also retrieve a md5 (or sha1) hash in the following manner:

FormsAuthentication.HashPasswordForStoringInConfigFile("somepassword", "md5");


comment posted by Christoff Truter on 2009-06-02 20:04:38

 


Write a comment

* *
*

* Required fields

Latest C# Snippets

FileSystemWatcher example

An example of how to monitor the filesystem using the filesytemwatcher class in ...

posted by Christoff Truter on 2009-06-27 22:08:12
View Snippet

 

MD5 hash

Calculate the MD5 hash of a given string...

posted by Christoff Truter on 2009-06-02 14:08:47
View Snippet

 

Converting doc to docx

Converting a word document to the "new" docx format is very simple using the off...

posted by Christoff Truter on 2009-05-08 14:22:55
View Snippet

 

Send email

Sending a simple email message...

posted by Christoff Truter on 2009-04-17 21:43:18
View Snippet

 

Resize Image

Resize an image...

posted by Christoff Truter on 2009-04-09 15:24:45
View Snippet

 

Anonymous Methods

Anonymous methods allow us to create inline methods without needing to define a ...

posted by Christoff Truter on 2009-02-22 22:04:33
View Snippet

 

Simple Indexer

An indexer makes an object act like an array....

posted by Christoff Truter on 2009-02-16 12:54:15
View Snippet

 

Deep clone/copy an object

MemberwiseClone only performs a shallow copy of an object, the following snippet...

posted by Christoff Truter on 2009-02-16 08:48:11
View Snippet

 

Extension method

a simple example of an extension method...

posted by Christoff Truter on 2009-02-14 19:53:12
View Snippet

 

Event

a simple example of how to create an event in C#...

posted by Christoff Truter on 2009-02-14 19:49:22
View Snippet