You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
916 B
40 lines
916 B
using System;
|
|
using System.Text;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Base64ConvertTool
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void button1_Click(object sender, EventArgs e)
|
|
{
|
|
if(string.IsNullOrEmpty(textBoxSrc.Text))
|
|
{
|
|
return;
|
|
}
|
|
|
|
string strText = textBoxSrc.Text;
|
|
|
|
byte[] byteText = Encoding.UTF8.GetBytes(strText);
|
|
|
|
string strbase64 = Convert.ToBase64String(byteText);
|
|
|
|
textBoxbase64.Text = strbase64;
|
|
|
|
//校验一下
|
|
byte[] checkbyte = Convert.FromBase64String(strbase64);
|
|
|
|
string checkstr = Encoding.UTF8.GetString(checkbyte);
|
|
|
|
if(checkstr != strText)
|
|
{
|
|
MessageBox.Show("convert error!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|