generating unique randon verification strings keys

For database driven web applications, when user signs up to your website, you may need to verify the email address of the person who signed up in your website.  You may send the verification email to the person's email address with the link that he/she needs to link in order to verify the email adress.

The key has to be supplied for security reasons; for example, http://example.com/verifyemail.aspx?key=--somekeytext--

To achieve this, you need to generate random but unique keys to avoid the inconsistency and maintain the security. Here is the code to generate the unique strings. You can then store this key in the user table and match it with the key text in the verification link.

 

public string GetUniqueKey()

{

  string Key = System.Guid.NewGuid().ToString();

  Key = Key.Replace("-", "");

  return Key;

}

 

There are several other ways available. but this is the simplest way.

These are the random keys that are generated using above code.

3fe76f2b27d04f518642852baabfbb90
8b579452ca2240a3b48bc87c6077614f
fc68e18bf57a4c498b112ca935257e92
447733fe67514f0d9f495105a0eadeaf
2d5469e00df84bfaacb0233560983a08

Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList






Quality & Affordable Web Development | About the Author | Hosted By Windows Hosting | Discuss With Experts At Webmaster Forums