aspx Tutorial

NET Articles,jQuery demo, with jQuery, online tutorial,Jquery, SilverLight, Javascript,,JSON, MVC,.NET Articles,demo, Web Services,
Advertise Here


Get our toolbar!


Posted by Aamir Hasan   on Tuesday, February 22, 2011 Total Views:  

This article describes how to secure your password before saving in database or XML file etc. Attacker always try to attack the database and stole all the passwords stored in database. It's developer responsibility to encrypt the password before sending to the database. One way encryption is secure to protect the passwords. One way encryption can encrypt the password but cannot decrypt.

In this example, I have used SHA512Managed Class. The size of SHA512Managed algorithm is 512 bits.

Here’s an example


Default.aspx page

<html xmlns="">

<head runat="server">





            background: #fefefe;

            font-size: .80em;

            font-family: "Helvetica Neue" , "Lucida Grande";

            margin: 0px;

            padding: 0px;

            color: #222;





    <form id="form1" runat="server">



        Implementing One-way Encryption in using csharp/VB.NET        </h2>



            <asp:TextBox ID="TextBox1" runat="server" />

            <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="Button1_Click" />

            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Enter the Password."

                ControlToValidate="TextBox1" ForeColor="Red"></asp:RequiredFieldValidator></br>

            <br />

            <asp:Label ID="Label1" runat="server" />








    protected void Button1_Click(object sender, EventArgs e)


        Label1.Text = "Encrypted password:  " +


    public static string getEncryptedCode(string inputString)


        byte[] Hash = new System.Security.Cryptography

        System.Text.StringBuilder outputString = new System.Text.StringBuilder();

        for (int i = 0; i < Hash.Length; i++)


        return outputString.ToString();




    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs)

        Label1.Text = "Encrypted password:  " +

    End Sub

    Public Shared Function getEncryptedCode(ByVal inputString As String) As String

        Dim Hash As Byte() = New System.Security.Cryptography

        Dim outputString As New System.Text.StringBuilder()

        For i As Integer = 0 To Hash.Length - 1



        Return outputString.ToString()

    End Function


Note:If you forgot your password, you cannot decrypt it; you have to reset your password.


SHA512Managed Class Supported in .net version 1.0, 1.1, 2.0, 3.0, 3.5 and 4.O

If you have alternative solution, please comments below to share with us.



One-way-Encryption-cSharp.rar (1.30 kb)

One-way-EncryptionVB.rar (1.23 kb)

See live demo

Protected by Copyscape Online Plagiarism Tool

Comments (3) -

Reyes Mitro
Reyes Mitro United States
3/16/2015 7:09:48 PM #

bookmarked!!, I like your website.

Raymond Rouleau
Raymond Rouleau United States
7/9/2015 4:18:42 AM #

I'll right away snatch your rss feed as I can not find your email subscription hyperlink or e-newsletter service. Do you have any? Kindly permit me recognise so that I may subscribe. Thanks.|

Emmett Kernell
Emmett Kernell United States
7/13/2015 7:59:59 AM #

This design is spectacular! You obviously know how to keep a reader entertained. Between your wit and your videos, I was almost moved to start my own blog (well, almost...HaHa!) Great job. I really loved what you had to say, and more than that, how you presented it. Too cool!|

Add comment

  Country flag

  • Comment
  • Preview

Advertizement 1
Advertizement 2
Advertizement 3
Advertizement 4
Advertizement 5