亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Base-64 char數組的長度無效

Base-64 char數組的長度無效

鴻蒙傳說 2019-10-17 14:55:16
如標題所示,我得到:Base-64 char數組的長度無效。我在這里已經閱讀了有關此問題的信息,似乎建議是將ViewState如果較大則存儲在SQL中。我正在使用具有大量數據收集功能的向導,因此我的ViewState很大。但是,在我轉向“數據庫存儲”解決方案之前,也許有人可以看看并告訴我是否還有其他選擇?我使用以下方法構造要發送的電子郵件:public void SendEmailAddressVerificationEmail(string userName, string to){    string msg = "Please click on the link below or paste it into a browser to verify your email account.<BR><BR>" +                    "<a href=\"" + _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +                    userName.Encrypt("verify") + "\">" +                    _configuration.RootURL + "Accounts/VerifyEmail.aspx?a=" +                    userName.Encrypt("verify") + "</a>";    SendEmail(to, "", "", "Account created! Email verification required.", msg);}Encrypt方法如下所示:public static string Encrypt(string clearText, string Password){    byte[] clearBytes = System.Text.Encoding.Unicode.GetBytes(clearText);    PasswordDeriveBytes pdb = new PasswordDeriveBytes(Password, new byte[] { 0x49, 0x76, 0x61, 0x6e, 0x20, 0x4d, 0x65, 0x64, 0x76, 0x65, 0x64, 0x65, 0x76 });    byte[] encryptedData = Encrypt(clearBytes, pdb.GetBytes(32), pdb.GetBytes(16));    return Convert.ToBase64String(encryptedData);}這是Hotmail中的HTML外觀:請單擊下面的鏈接或將其粘貼到瀏覽器中以驗證您的電子郵件帳戶。http:// localhost:1563 / Accounts / VerifyEmail.aspx?a = YOHY57xYRENEOu3H + FGq1Rf09AZAI56EPjfwuK8XWKg =在接收端,VerifyEmail.aspx.cs頁面的行如下: string username = Cryptography.Decrypt(_webContext.UserNameToVerify, "verify");這是UserNameToVerify的獲取方法:public string UserNameToVerify{    get    {        return GetQueryStringValue("a").ToString();    }}這是GetQueryStringValue方法:private static string GetQueryStringValue(string key){    return HttpContext.Current.Request.QueryString.Get(key);}解密方法如下所示:public static string Decrypt(string cipherText, string password){    **// THE ERROR IS THROWN HERE!!**    byte[] cipherBytes = Convert.FromBase64String(cipherText);可以通過代碼修復糾正此錯誤,還是必須將ViewState存儲在數據庫中?
查看完整描述

3 回答

  • 3 回答
  • 0 關注
  • 740 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號