<Window x:Class="Base64Convertor.MainWindow"

xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

Title="MainWindow" Height="387" Width="629">

<Grid>

<Grid.RowDefinitions>

<RowDefinition/>

<RowDefinition Height="auto"/>

<RowDefinition/>

</Grid.RowDefinitions>

<GroupBox Grid.Row="0" Header="Input" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="groupBox1" VerticalAlignment="Stretch">

<TextBox Name="txtInput" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Yellow" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" />

</GroupBox>

 

<TabControl Grid.Row="1">

<TabItem Header="Encode" >

<StackPanel Grid.Row="1" Orientation="Horizontal">

<Button Name="btnEncodeInputText" Content="From Input Text" Height="25" Margin="5" Click="btnEncodeInputText_Click" />

<Button Name="btnEncodeInputFile" Content="From Input File" Height="25" Margin="5" Click="btnEncodeInputFile_Click" />

<Button Name="btnCopyToClipboard" Content="Copy to Clipboard" Height="25" Margin="5" Click="btnCopyToClipboard_Click" />

</StackPanel>

</TabItem>

<TabItem Header="Decode">

<StackPanel Grid.Row="1" Orientation="Horizontal">

<Button Name="btnDecodeToOutput" Content="Decode to Output" Margin="5" Height="25" Click="btnDecodeToOutput_Click" />

<Button Name="btnDecodeToFile" Content="Decode to File" Height="25" Margin="5" Click="btnDecodeToFile_Click" />

</StackPanel>

</TabItem>

</TabControl>

 

<GroupBox Grid.Row="2" Header="Output" HorizontalAlignment="Stretch" Margin="0,0,0,0" Name="groupBox2" VerticalAlignment="Stretch">

<TextBox Name="txtOutput" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Background="Yellow" TextWrapping="Wrap" VerticalScrollBarVisibility="Auto" AcceptsReturn="True" />

</GroupBox>

</Grid>

</Window>

 

public
partial
class
MainWindow : Window

{

public MainWindow()

{

InitializeComponent();

}

 

private
void btnEncodeInputText_Click(object sender, RoutedEventArgs e)

{

txtOutput.Text = Convert.ToBase64String(Encoding.UTF8.GetBytes(txtInput.Text.Trim()));

}

 

private
void btnDecodeToOutput_Click(object sender, RoutedEventArgs e)

{

txtOutput.Text = Encoding.UTF8.GetString(Convert.FromBase64String(txtInput.Text.Trim()));

}

 

private
void btnEncodeInputFile_Click(object sender, RoutedEventArgs e)

{

OpenFileDialog ofd = new
OpenFileDialog();

if (ofd.ShowDialog().Value == true)

{

var fileContent = File.ReadAllBytes(ofd.FileName);

txtOutput.Text = Convert.ToBase64String(fileContent);

MessageBox.Show("done!");

}

}

 

private
void btnCopyToClipboard_Click(object sender, RoutedEventArgs e)

{

Clipboard.SetText(txtOutput.Text);

}

 

private
void btnDecodeToFile_Click(object sender, RoutedEventArgs e)

{

SaveFileDialog sfd = new
SaveFileDialog();

if (sfd.ShowDialog().Value == true)

{

var fileContent = Convert.FromBase64String(txtInput.Text.Trim());

File.WriteAllBytes(sfd.FileName, fileContent);

MessageBox.Show("done!");

}

}

}

Base64 Converter的更多相关文章

  1. 加密代理和Retrofit解密Converter

    最近在研究安卓的Retrofit框架,服务器的数据全部用加密算法加密了,发现无法使用"com.squareup.retrofit2:converter-gson:2.1.0"Jar ...

  2. Bugku一段base64

    本文转自:本文为博主原创文章,如有转载请注明出处,谢谢. https://blog.csdn.net/pdsu161530247/article/details/74640746 链接中高手给出的解题 ...

  3. WPF converter(包含传递复杂参数)

    单值转换器 将单一值转换为特定类型的值,以日期转换为例如下: 1.定制DateConverter类,其中当值从绑定源传播给绑定目标时,调用方法Convert. 1 public class DateC ...

  4. SSL Converter & Formats

    https://www.sslshopper.com/ssl-converter.html PEM Format The PEM format is the most common format th ...

  5. coding++:js实现基于Base64的编码及解码

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  6. URL安全的Base64编码

    Base64编码可用于在HTTP环境下传递较长的标识信息.在其他应用程序中,也常常需要把二进制数据编码为适合放在URL(包括隐藏表单域)中的形式.此时,采用Base64编码不仅比较简短,同时也具有不可 ...

  7. Base64编码

    Base64编码 写在前面 今天在做一个Android app时遇到了一个问题:Android端采用ASE对称加密的数据在JavaWeb(jre1.8.0_7)后台解密时,居然解密失败了!经过测试后发 ...

  8. Android数据加密之Base64编码算法

    前言: 前面学习总结了平时开发中遇见的各种数据加密方式,最终都会对加密后的二进制数据进行Base64编码,起到一种二次加密的效果,其实呢Base64从严格意义上来说的话不是一种加密算法,而是一种编码算 ...

  9. java单向加密算法小结(1)--Base64算法

    从这一篇起整理一下常见的加密算法以及在java中使用的demo,首先从最简单的开始. 简单了解 Base64严格来说并不是一种加密算法,而是一种编码/解码的实现方式. 我们都知道,数据在计算机网络之间 ...

随机推荐

  1. Bootflat – 基于 Bootstrap CSS 框架的扁平化界面

    Bootflat 是一个开源的扁平化的 UI 工具包,基于 Bootstrap 3.1.0 CSS 框架.它为 Web 开发人员提供了一个创建优雅的 Web 应用程序的更快,更容易和更少的重复任务的途 ...

  2. 【分享】学长的安利来了~~O(∩_∩)O

    前言:应栋哥要求,学长把演讲稿稍微整理下发布出来,这可以算是一篇安利文,也可以说是一篇经历文吧.作为一个确确实实从软工里收获到挺多东西的过来人,学长希望可以通过学长的经历来让你们对软工更加期待. 安利 ...

  3. ASP.NET MVC案例——————拦截器

    摘要      本文将对“MVC公告发布系统”的发布公告功能添加日志功能和异常处理功能,借此来讨论ASP.NET MVC中拦截器的使用方法. 一个小难题      我们继续完善“MVC公告发布系统”, ...

  4. log4net 既要按日期分割日志文件,又要按文件大小分割。

    <appender name="DebugAppender" type="log4net.Appender.RollingFileAppender"> ...

  5. autofac 注入中i遇到的泛型传参问题

    using Autofac; using IService; using System; using System.Collections.Generic; using System.Linq; us ...

  6. Windows Server 2012中配置AD域服务

    1.安装完AD域服务后,我们返回服务器管理器界面,点击"将此服务器提升为域控制器",选择"添加新林". 输入域名称:contoso.com 2.按图中所示选择林 ...

  7. 【C#】VS2015开发环境的安装和配置(三)2016-08-03更新

    分类:C#.VS2015.WPF.ASP.NET MVC.Android.iOS.Unity3D: 更新日期:2016-08-03 控制台应用程序.WPF应用程序直接创建即可,这里就不再介绍了.下面仅 ...

  8. windbg学习进阶之——windbg环境变量配置

    接触性能调优以来一直想学下windbg分析dump,每次看老师几个命令就能找到很底层的问题原因那简直就是羡慕加崇拜啊~但是这接近一年了,愣是没啥进展呢,主要就是在今天整理的这部分卡住了...这理由找的 ...

  9. C#-INotifyPropertyChanged(解决数据绑定的界面刷新问题)

    最近做项目用到DataGridView,用它绑定数据源后,如果数据源中的数据修改无法及时刷新到控件上,必须切换单元格的焦点才能导致刷新显示新数值,通过查官方文档,用INotifyPropertyCha ...

  10. 速战速决 (1) - PHP: 概述, 常量, 变量, 运算符, 表达式, 控制语句

    [源码下载] 速战速决 (1) - PHP: 概述, 常量, 变量, 运算符, 表达式, 控制语句 作者:webabcd 介绍速战速决 之 PHP 概述 常量 变量 运算符 表达式 控制语句 示例1. ...