how to ENCRYPTION & DECRYPTION Password

Default.aspx


  Enter PassWord :      7777    

              Button1

              Label1   Nzc3Nw
              Label2   7777


Default.aspx.CS

private string Decryptdata(string encryptpwd)
    {
        string decryptpwd = string.Empty;
        UTF8Encoding encodepwd = new UTF8Encoding();



        Decoder Decode = encodepwd.GetDecoder();
        byte[] todecode_byte = Convert.FromBase64String(encryptpwd);
        int charCount = Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
        char[] decoded_char = new char[charCount];
        Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
        decryptpwd = new String(decoded_char);
        return decryptpwd;
    }






private string Encryptdata(string password)
    {
        string strmsg = string.Empty;
        byte[] encode = new byte[password.Length];
        encode = Encoding.UTF8.GetBytes(password);
        strmsg = Convert.ToBase64String(encode);
        return strmsg;
    }



 protected void Button1_Click(object sender, EventArgs e)
    {

        string strpassword = Encryptdata(txtPassword.Text);
        Label1.Text= strpassword;

       string decryptPW = Decryptdata(Label1.Text); 
       Label2.Text= decryptPW;
   }