最後一次是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