<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. Hadoop阅读笔记(五)——重返Hadoop目录结构

    常言道:男人是视觉动物.我觉得不完全对,我的理解是范围再扩大点,不管男人女人都是视觉动物.某些场合(比如面试.初次见面等),别人没有那么多的闲暇时间听你诉说过往以塑立一个关于你的完整模型.所以,第一眼 ...

  2. TCP/IP之四书五经[转自2003.12程序员]

    TCP/IP协议是当前广域网和局域网通用的网络协议,因此,基于TCP/IP的编程就格外重要.从应用上来说,现在直接利用C层次Socket API进行TCP/IP编程的人确实越来越少了,各种现成的框架( ...

  3. 【视频处理】YUV格式说明

    YUV,是一种颜色编码方法,Y表示明亮度(Luminance.Luma),U和V则是色度.浓度(Chrominance.Chroma). YUV,Y`UV,YCbCr,YPbPr等都可以称为YUV,彼 ...

  4. js限制文本框只可以输入数字

    封装了一下,要用的话直接调用下面getEvent函数即可   function getEvent() { if (document.all) { return window.event; //for ...

  5. Visual Studio 2012 Update 4 RC 启动调试失败解决方案

    以下解决办法适用于任何Visual Studio开发环境,及Windows NT 6.1以上系统. 系统:Windows 8.1 Enterprise x64 RTM 开发环境:Visual Stud ...

  6. [Asp.net 5] DependencyInjection项目代码分析4-微软的实现(3)

    这个系列已经写了5篇,链接地址如下: [Asp.net 5] DependencyInjection项目代码分析 [Asp.net 5] DependencyInjection项目代码分析2-Auto ...

  7. wpf 自定义圆形按钮

    wpf 自定义圆形按钮 效果图 默认样式 获取焦点样式 点击样式 下面是实现代码: 一个是自定义控件类,一个是控件类皮肤 using System; using System.Collections. ...

  8. Guava学习笔记:Immutable(不可变)集合

    不可变集合,顾名思义就是说集合是不可被修改的.集合的数据项是在创建的时候提供,并且在整个生命周期中都不可改变. 为什么要用immutable对象?immutable对象有以下的优点: 1.对不可靠的客 ...

  9. 让.NET 4.0支持TLS1.2协议

    The default System.Net.ServicePointManager.SecurityProtocol in both .NET 4.0/4.5 is SecurityProtocol ...

  10. 【转】正确设置php-fpm子进程用户,提高网站安全性防挂马

    原文地址:http://www.myhack58.com/Article/60/61/2013/37209.htm 根据生产环境不断反馈,发现不断有 PHP网站被挂木马,绝大部分原因是因为权限设置不合 ...