Simply open snippet compiler an essential tool at ( ) and add a reference to system.web
then add:
using System.Web.Security;
and the code is simply:
string hashedText = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("test", "SHA1");
Console.WriteLine(hashedText);
if you want the full class to use in snippet compiler for copying and pasting it is simply
using System;
using System.Collections.Generic;
using System.Web.Security;
public class HashPassword
{
public static void RunSnippet()
{
string hashedText = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile("test", "SHA1");
Console.WriteLine(hashedText);
}
#region Helper methods
public static void Main()
{
try
{
RunSnippet();
}
catch (Exception e)
{
string error = string.Format("---\nThe following error occurred while executing the snippet:\n{0}\n---", e.ToString());
Console.WriteLine(error);
}
finally
{
Console.Write("Press any key to continue...");
Console.ReadKey();
}
}
private static void WL(object text, params object[] args)
{
Console.WriteLine(text.ToString(), args);
}
private static void RL()
{
Console.ReadLine();
}
private static void Break()
{
System.Diagnostics.Debugger.Break();
}
#endregion
}
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.