diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-25 01:25:36 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2020-08-25 01:25:36 +0300 |
| commit | cc39950f6dd2a41f029d8d878e132ec80d9b0dd0 (patch) | |
| tree | 474ff5c7f2101e424bd0c1a8356e5a0fb701af06 /Software/Visual_Studio/Tango.Core | |
| parent | 8c3729dc78b533fff733564bab871b1bd69a75c0 (diff) | |
| download | Tango-cc39950f6dd2a41f029d8d878e132ec80d9b0dd0.tar.gz Tango-cc39950f6dd2a41f029d8d878e132ec80d9b0dd0.zip | |
Tango FSE + FSE Log Viewer + Custom Protocol - Completed !!!
Diffstat (limited to 'Software/Visual_Studio/Tango.Core')
| -rw-r--r-- | Software/Visual_Studio/Tango.Core/Cryptography/MachineLevelCryptographer.cs | 40 | ||||
| -rw-r--r-- | Software/Visual_Studio/Tango.Core/Tango.Core.csproj | 4 |
2 files changed, 43 insertions, 1 deletions
diff --git a/Software/Visual_Studio/Tango.Core/Cryptography/MachineLevelCryptographer.cs b/Software/Visual_Studio/Tango.Core/Cryptography/MachineLevelCryptographer.cs new file mode 100644 index 000000000..04fd036a4 --- /dev/null +++ b/Software/Visual_Studio/Tango.Core/Cryptography/MachineLevelCryptographer.cs @@ -0,0 +1,40 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Security.Cryptography; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.Core.Cryptography +{ + public class MachineLevelCryptographer : ICryptographer + { + public string Encrypt(string text) + { + return Encrypt(text, "Twine1357"); + } + + public string Encrypt(string text, string key) + { + return Convert.ToBase64String( + ProtectedData.Protect( + Encoding.UTF8.GetBytes(text) + , key != null ? Encoding.UTF8.GetBytes(key) : null + , DataProtectionScope.LocalMachine)); + } + + public string Decrypt(string text) + { + return Decrypt(text, "Twine1357"); + } + + public string Decrypt(string text, string key) + { + return Encoding.UTF8.GetString( + ProtectedData.Unprotect( + Convert.FromBase64String(text) + , key != null ? Encoding.UTF8.GetBytes(key) : null + , DataProtectionScope.LocalMachine)); + } + } +} diff --git a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj index 2ecd441f2..7b94b40a8 100644 --- a/Software/Visual_Studio/Tango.Core/Tango.Core.csproj +++ b/Software/Visual_Studio/Tango.Core/Tango.Core.csproj @@ -81,6 +81,7 @@ <Reference Include="System.Net.Http" /> <Reference Include="System.Runtime" /> <Reference Include="System.Runtime.Serialization" /> + <Reference Include="System.Security" /> <Reference Include="System.Windows" /> <Reference Include="System.Windows.Forms" /> <Reference Include="System.Xaml" /> @@ -97,6 +98,7 @@ </Compile> <Compile Include="Bson\BsonUtcSerializer.cs" /> <Compile Include="Components\CmdCommand.cs" /> + <Compile Include="Cryptography\MachineLevelCryptographer.cs" /> <Compile Include="CustomAttributes\PropertyIndexAttribute.cs" /> <Compile Include="CustomAttributes\StringFormatAttribute.cs" /> <Compile Include="ExtensionMethods\BooleanExtensions.cs" /> @@ -217,7 +219,7 @@ <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <ProjectExtensions> <VisualStudio> - <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_UseGlobalSettings="False" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" /> + <UserProperties BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UseGlobalSettings="False" BuildVersion_StartDate="2000/1/1" /> </VisualStudio> </ProjectExtensions> <Import Project="..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets" Condition="Exists('..\packages\System.Data.SQLite.Core.1.0.108.0\build\net46\System.Data.SQLite.Core.targets')" /> |
