示例#1
0
 public static AESEncryptionWrapper getInstance()
 {
     if (instance == null)
     {
         instance = new AESEncryptionWrapper();
     }
     return(instance);
 }
示例#2
0
文件: User.cs 项目: Achimeir/RFAS-
 public User(string userName, string userPass, string RoleName, Classification classification = Classification.None)
 {
     this.userName       = userName;
     this.userPass       = userPass;
     this.classification = classification;
     this.userRole       = new Role(RoleName);
     this.userKeys       = AESEncryptionWrapper.getInstance().generateKeyAndVector();
 }
示例#3
0
文件: Files.cs 项目: Achimeir/RFAS-
 public override void Encrypt(byte[] key, byte[] iv, string encryptData = null)
 {
     try
     {
         var    input          = System.IO.File.ReadAllText(this.filePath);
         byte[] encryptedBytes = AESEncryptionWrapper.getInstance().EncryptStringToBytes(input, key, iv);
         var    cypherText     = Convert.ToBase64String(encryptedBytes);
         System.IO.File.WriteAllText(this.filePath, cypherText);
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show(e.Message + " ההצפנה נכשלה מהסיבה", "תקלה", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }
示例#4
0
文件: Files.cs 项目: Achimeir/RFAS-
 public override void Decrypt(byte[] key, byte[] iv)
 {
     try
     {
         var    input          = System.IO.File.ReadAllText(this.filePath);
         var    inputInBytes   = Convert.FromBase64String(input);
         string descryptedtext = AESEncryptionWrapper.getInstance().DecryptStringFromBytes(inputInBytes, key, iv);
         System.IO.File.WriteAllText(this.filePath, descryptedtext);
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show(e.Message + " הפענוח נכשל מהסיבה", "תקלה", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Error);
     }
 }