最后一次是PBL与ENC并将其存储db和现在的PBL是在分解和从DB检索数据则显示错误作为一个更描述
的输入是不一个有效的Base-64字符串,因为它含有非基本的填充字符
代码是这样的间64 字符,两个以上的填充字符,或一个非空白 字符:
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Security.Cryptography;
using System.Data.SqlClient;
namespace WebApplication5
{
public partial class WebForm4 : System.Web.UI.Page
{
SqlConnection connection;
protected void Page_Load(object sender, EventArgs e)
{
connection = new SqlConnection(ConfigurationManager.ConnectionStrings["TestQueryConnectionString"].ConnectionString);
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlConnection con1 = new SqlConnection(ConfigurationManager.ConnectionStrings["TestQueryConnectionString"].ConnectionString);
con1.Open();
SqlCommand cmd1 = new SqlCommand("select * from admin where [email protected] and [email protected] ", con1);
cmd1.Parameters.AddWithValue("@username", txtUserName.Text);
string strpassword = DecodeFrom64(txtPassword.Text);
cmd1.Parameters.AddWithValue("@password", txtPassword.Text);
SqlDataAdapter da = new SqlDataAdapter(cmd1);
DataTable dt = new DataTable();
da.Fill(dt);
if (dt.Rows.Count > 0)
{
Response.Redirect("emplist.aspx");
}
else
{
ClientScript.RegisterStartupScript(Page.GetType(), "validation", "<script language='javascript'>alert('Invalid Username and Password')</script>");
}
con1.Close();
}
protected void btnClear_Click(object sender, EventArgs e)
{
txtUserName.Text = "";
txtPassword.Text = "";
}
public string DecodeFrom64(string encodedData)
{
System.Text.UTF8Encoding encoder = new System.Text.UTF8Encoding();
System.Text.Decoder utf8Decode = encoder.GetDecoder();
byte[] todecode_byte = Convert.FromBase64String(encodedData);
int charCount = utf8Decode.GetCharCount(todecode_byte, 0, todecode_byte.Length);
char[] decoded_char = new char[charCount];
utf8Decode.GetChars(todecode_byte, 0, todecode_byte.Length, decoded_char, 0);
string result = new String(decoded_char);
return result;
}
}
}
@ user2189723请给出正确的标题名称。 – 2013-03-20 07:48:40
你不会/不能在问题中标记一个人,我说如果它有一个新问题,然后问一个新问题。此外,你需要给你的问题更好的标题,否则你可能会得到赞誉。 – Habib 2013-03-20 08:43:20
请写出整个单词,而不是使用简写。你继续写“pbl”和“enc”这样的东西的方式会让你的问题很难理解。 – jadarnel27 2013-06-04 14:15:41