-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
175 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 not shown.