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)); } } }