From cc39950f6dd2a41f029d8d878e132ec80d9b0dd0 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Tue, 25 Aug 2020 01:25:36 +0300 Subject: Tango FSE + FSE Log Viewer + Custom Protocol - Completed !!! --- .../Cryptography/MachineLevelCryptographer.cs | 40 ++++++++++++++++++++++ .../Visual_Studio/Tango.Core/Tango.Core.csproj | 4 ++- 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 Software/Visual_Studio/Tango.Core/Cryptography/MachineLevelCryptographer.cs (limited to 'Software/Visual_Studio/Tango.Core') 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 @@ + @@ -97,6 +98,7 @@ + @@ -217,7 +219,7 @@ - + -- cgit v1.3.1