Exemplo n.º 1
0
        public bool SaveEncryptionRecord(EncryptionHistoryModel encryption)
        {
            try
            {
                using (var db = new WebApiTrainingEntities())
                {
                    db.RijndaelAESEncryptionHistories.Add(new RijndaelAESEncryptionHistory
                    {
                        EncryptedPhrase = encryption.EncryptedPhrase,
                        PhraseEncryptionRequestsCount = encryption.Count,
                        EncryptionKeyUsed             = encryption.KeyBytes,
                        SourcePhrase         = encryption.Phrase,
                        EncryptionVectorUsed = encryption.VectorBytes
                    });

                    db.SaveChanges();

                    return(true);
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
        }
 public StorageSettingsModel GetFileStorageSettings()
 {
     using (var db = new WebApiTrainingEntities())
     {
         return(db.FileStorageSettings.Select(x =>
                                              new StorageSettingsModel
         {
             StorageFolder = x.StorageLocalFolder
         }).FirstOrDefault());
     }
 }
Exemplo n.º 3
0
 public IEnumerable <EncryptionHistoryModel> GetEncryptionHistory()
 {
     using (var db = new WebApiTrainingEntities())
     {
         return(db.RijndaelAESEncryptionHistories.Select(x => new EncryptionHistoryModel
         {
             EncryptedPhrase = x.EncryptedPhrase,
             Phrase = x.SourcePhrase,
             Count = x.PhraseEncryptionRequestsCount,
             KeyBytes = x.EncryptionKeyUsed,
             VectorBytes = x.EncryptionVectorUsed
         }));
     }
 }