C#中將字串轉成 Base 64 編碼 (加密--解密)

來源:互聯網
上載者:User

標籤:bpa   tar   doc   ext   xhtml 1.0   ati   加密解密   ring   head   

 1 <%@ Page Language="C#" AutoEventWireup="true" CodeFile="Base64.aspx.cs" Inherits="Base64" %> 2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 3 <html xmlns="http://www.w3.org/1999/xhtml" > 4 <head runat="server"> 5     <title> Base64加密解密 6 </title> 7 </head> 8 <body> 9     <form id="form1" runat="server">10     <div>11         <span style="font-size: 24pt; color: #006633" mce_style="font-size: 24pt; color: #006633">           12                               Base64加密解密</span><br />13         <br />14         <br />15     <asp:TextBox ID="txtChar" runat="server"></asp:TextBox> 16     <asp:Button ID="btnEncrypt" runat="server" Text="加密" OnClick="btnBase64_Click" />17         <asp:Button ID="btnExtract" runat="server" OnClick="Button1_Click" Text="解密" /><br />18         <br />19     <asp:Label ID="lblMessage" runat="server" Width="211px" ></asp:Label></div>20     </form>21 </body>22 </html>23 24 25 26 27 28 using System;29 using System.Data;30 using System.Configuration;31 using System.Collections;32 using System.Web;33 using System.Web.Security;34 using System.Web.UI;35 using System.Web.UI.WebControls;36 using System.Web.UI.WebControls.WebParts;37 using System.Web.UI.HtmlControls;38 public partial class Base64 : System.Web.UI.Page39 {40     protected void Page_Load(object sender, EventArgs e)41     {42     }43     protected void btnBase64_Click(object sender, EventArgs e)44     {45         string a = txtChar.Text;46         byte[] b = System.Text.Encoding.Default.GetBytes(a);47         lblMessage.Text =  Convert.ToBase64String(b);48     }49     protected void Button1_Click(object sender, EventArgs e)50     {51         string a = txtChar.Text;52         byte[] c = Convert.FromBase64String(a);53         lblMessage.Text = System.Text.Encoding.Default.GetString(c);54     }55 }

 

C#中將字串轉成 Base 64 編碼 (加密--解密)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.