diff --git a/Base64encoder.sln b/Base64encoder.sln new file mode 100644 index 0000000..b433e8f --- /dev/null +++ b/Base64encoder.sln @@ -0,0 +1,42 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.0.32126.317 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Base64encoder", "Base64encoder\Base64encoder.csproj", "{CA02C7C7-9449-4F15-A6C8-886918B02356}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Base64encoderTests", "Base64encoderTests\Base64encoderTests.csproj", "{A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CA02C7C7-9449-4F15-A6C8-886918B02356}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CA02C7C7-9449-4F15-A6C8-886918B02356}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CA02C7C7-9449-4F15-A6C8-886918B02356}.Debug|x64.ActiveCfg = Debug|x64 + {CA02C7C7-9449-4F15-A6C8-886918B02356}.Debug|x64.Build.0 = Debug|x64 + {CA02C7C7-9449-4F15-A6C8-886918B02356}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CA02C7C7-9449-4F15-A6C8-886918B02356}.Release|Any CPU.Build.0 = Release|Any CPU + {CA02C7C7-9449-4F15-A6C8-886918B02356}.Release|x64.ActiveCfg = Release|x64 + {CA02C7C7-9449-4F15-A6C8-886918B02356}.Release|x64.Build.0 = Release|x64 + {A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}.Debug|x64.ActiveCfg = Debug|Any CPU + {A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}.Debug|x64.Build.0 = Debug|Any CPU + {A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}.Release|Any CPU.Build.0 = Release|Any CPU + {A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}.Release|x64.ActiveCfg = Release|Any CPU + {A95BADAC-7AC8-4D7A-ACA8-6ABE9BAEA94E}.Release|x64.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + VisualSVNWorkingCopyRoot = . + SolutionGuid = {12CCE259-8107-43EB-8F2E-526B3D47F8A4} + EndGlobalSection +EndGlobal diff --git a/Base64encoder/Base64encoder.csproj b/Base64encoder/Base64encoder.csproj new file mode 100644 index 0000000..25059bf --- /dev/null +++ b/Base64encoder/Base64encoder.csproj @@ -0,0 +1,18 @@ + + + + net5.0 + Ru.Pfr.Crypto.Base64encoder + AnyCPU;x64 + True + + + + x64 + + + + x64 + + + diff --git a/Base64encoder/Encoder64.cs b/Base64encoder/Encoder64.cs new file mode 100644 index 0000000..e568e80 --- /dev/null +++ b/Base64encoder/Encoder64.cs @@ -0,0 +1,27 @@ +using System; +using System.Security.Cryptography; +using System.Text; + +namespace Ru.Pfr.Crypto.Base64encoder +{ + public static class Encoder64 + { + public static String EncodeTo64(String _string) + { + string result; + try + { + SHA1Managed hasher = new(); + byte[] pwdBytes = Encoding.Default.GetBytes(_string); + byte[] keyBytes = hasher.ComputeHash(pwdBytes); + hasher.Dispose(); + result = Convert.ToBase64String(keyBytes); + } + catch (Exception ex) + { + throw new Exception(ex.Message, ex); + } + return result; + } + } +} \ No newline at end of file diff --git a/Base64encoderTests/Base64encoderTests.csproj b/Base64encoderTests/Base64encoderTests.csproj new file mode 100644 index 0000000..dc9b449 --- /dev/null +++ b/Base64encoderTests/Base64encoderTests.csproj @@ -0,0 +1,24 @@ + + + + .NETCoreApp,Version=v5.0 + + false + + + + x64 + + + + + + + + + + + + + + diff --git a/Base64encoderTests/Encoder64Tests.cs b/Base64encoderTests/Encoder64Tests.cs new file mode 100644 index 0000000..46232af --- /dev/null +++ b/Base64encoderTests/Encoder64Tests.cs @@ -0,0 +1,22 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Ru.Pfr.Crypto.Base64encoder; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Ru.Pfr.Crypto.Base64encoder.Tests +{ + [TestClass()] + public class Encoder64Tests + { + [TestMethod()] + public void EncodeTo64Test() + { + String result = Encoder64.EncodeTo64("MyPassword"); + Console.WriteLine(result); + + } + } +} \ No newline at end of file