Skip to content

Commit

Permalink
添加项目文件。
Browse files Browse the repository at this point in the history
  • Loading branch information
HRxiaohu committed Nov 8, 2022
1 parent f7e9e56 commit 2e70a9d
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 0 deletions.
25 changes: 25 additions & 0 deletions LearnCsharp.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.3.32929.385
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LearnCsharp", "LearnCsharp\LearnCsharp.csproj", "{95A3676E-9317-44A3-8D8A-0CC84A3A5275}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{95A3676E-9317-44A3-8D8A-0CC84A3A5275}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{95A3676E-9317-44A3-8D8A-0CC84A3A5275}.Debug|Any CPU.Build.0 = Debug|Any CPU
{95A3676E-9317-44A3-8D8A-0CC84A3A5275}.Release|Any CPU.ActiveCfg = Release|Any CPU
{95A3676E-9317-44A3-8D8A-0CC84A3A5275}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {89031123-55F4-40EB-B5AC-F6D142D6AB22}
EndGlobalSection
EndGlobal
33 changes: 33 additions & 0 deletions LearnCsharp/Decoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Base64Tools
{
internal class Decoder
{
public static string Decode(string value)
{
if (value == null || value == "")
{
Console.WriteLine("请输入要解码的字符串:\a");
Console.WriteLine("---\n");
return "false";
}
else
{
try
{
byte[] bytes = Convert.FromBase64String(value);
return Encoding.UTF8.GetString(bytes);
}
catch (FormatException)
{
return "false";
}
}
}
}
}
23 changes: 23 additions & 0 deletions LearnCsharp/LearnCsharp.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<FileVersion></FileVersion>
<AssemblyVersion></AssemblyVersion>
<NeutralLanguage>zh-CN</NeutralLanguage>
<PackageIcon></PackageIcon>
<Copyright>2022©HRxiaohu</Copyright>
<Product></Product>
<AssemblyName>Base64Tools</AssemblyName>
<RootNamespace>Base64Tools</RootNamespace>
<ApplicationIcon>下载.ico</ApplicationIcon>
</PropertyGroup>

<ItemGroup>
<Content Include="下载.ico" />
</ItemGroup>

</Project>
62 changes: 62 additions & 0 deletions LearnCsharp/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
using static Base64Tools.Uncoder;
using static Base64Tools.Decoder;
using System.Text;

namespace Base64Tools
{
class Tools
{
public static void Main(string[] args)
{
Console.WriteLine("----------------------------------------------------------------");
Console.WriteLine(" ____ __ _ _ _____ _\r\n| __ ) __ _ ___ ___ / /_ | || | | ____|_ __ ___ ___ __| | ___ _ __\r\n| _ \\ / _` / __|/ _ | '_ \\| || |_| _| | '_ \\ / __/ _ \\ / _` |/ _ | '__|\r\n| |_) | (_| \\__ | __| (_) |__ _| |___| | | | (_| (_) | (_| | __| |\r\n|____/ \\__,_|___/\\___|\\___/ |_| |_____|_| |_|\\___\\___/ \\__,_|\\___|_|\n");
Console.WriteLine("----------------------------------------------------------------");
start:
Console.WriteLine("您是想进行解码还是编码呢?请输入 解码/编码");
string answer = Console.ReadLine();
if (answer == "解码")
{
decoder:
Console.WriteLine("请输入要解码的Base64字符串");
string base64 = Console.ReadLine();
string base64Return = Decode(base64);
if (base64Return == "false")
{
Console.WriteLine("请输入正确的Base64字符串\a");
Console.WriteLine("---\a");
goto decoder;
}
else
{
Console.WriteLine("原文为:"+base64Return+"\n\a");
Console.WriteLine("解码完毕");
Console.WriteLine("---\n");
}
}
else if (answer == "编码")
{
uncoder:
Console.WriteLine("请输入要编码的Base64字符串:");
string base64 = Console.ReadLine();
string base64Return = Uncode(base64);
if (base64Return == "false")
{
Console.WriteLine("请输入正确的Base64字符串\a");
Console.WriteLine("---\n");
goto uncoder;
}
else
{
Console.WriteLine("原文为:"+base64Return +"\n\a");
Console.WriteLine("编码完毕");
Console.WriteLine("---\n");
}
}
else
{
Console.WriteLine("请输入正确的选项\n\a");
goto start;
}
}
}
}
32 changes: 32 additions & 0 deletions LearnCsharp/Uncoder.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Base64Tools
{
internal class Uncoder
{
public static string Uncode(string value)
{
if (value == null || value == "")
{
Console.WriteLine("请输入要解码的字符串\n\a");
return "false";
}
else
{
try
{
byte[] bytes = Encoding.UTF8.GetBytes(value);
return Convert.ToBase64String(bytes);
}
catch (FormatException)
{
return "false";
}
}
}
}
}
Binary file added LearnCsharp/下载.ico
Binary file not shown.

0 comments on commit 2e70a9d

Please sign in to comment.