Esempio n. 1
0
 public void Lock()
 {
     Logger.Debug("Locking");
     Logger.Debug("Perform encryption");
     _lockedContent = _encryptionStrategy.Encrypt(Template, _container.GetContent());
     Logger.Debug("lockedContent created");
     Template = _encryptionStrategy.Encrypt(_lockedContent, Template);
     IsLocked = true;
     Logger.Debug("Locked");
 }
Esempio n. 2
0
 public string Encrypt()
 {
     try
     {
         return(_strategy.Encrypt(_message));
     }
     catch (NullReferenceException e)
     {
         System.Windows.Forms.MessageBox.Show("Strategy for encryption not set." + e.ToString(), "Strategy not set.",
                                              System.Windows.Forms.MessageBoxButtons.OK,
                                              System.Windows.Forms.MessageBoxIcon.Error,
                                              System.Windows.Forms.MessageBoxDefaultButton.Button1);
         return(null);
     }
 }
Esempio n. 3
0
        public bool SerializeObject(object o)
        {
            try
            {
                EnsureFolder(_configuration.StorageLocation);

                string json      = JsonConvert.SerializeObject(o);
                string encrypted = _encryptionStrategy.Encrypt(json, _configuration.DecryptedMasterKey);

                WriteToFile(_configuration.GetFullPath(), encrypted, 0);

                return(true);
            }
            catch (Exception ex)
            {
                _logger.Error(ex.Message);
            }

            return(false);
        }
Esempio n. 4
0
        public void Send(string message)
        {
            var encryptedMessage = encryptionAlgorithm.Encrypt(message);

            Console.WriteLine($"Sending the encrypted message: {encryptedMessage}.");
        }
Esempio n. 5
0
 public string Encrypt(string content)
 {
     return(_strategy.Encrypt(content));
 }