Beispiel #1
0
 public static void Serial(string FilePath, LicObj obj)
 {
     using (FileStream fileStream = new FileStream(FilePath, FileMode.Create))
     {
         byte[] inputByteArray = SerializeObject(obj);
         inputByteArray = Encry.EncryptDES(inputByteArray, keys);
         fileStream.Write(inputByteArray, 0, inputByteArray.Length);
     }
 }
Beispiel #2
0
 public static LicObj DeserializeObject(string Filepath)
 {
     using (FileStream fileStream = new FileStream(Filepath, FileMode.Open))
     {
         fileStream.Seek(0L, SeekOrigin.Begin);
         byte[] array = new byte[fileStream.Length];
         fileStream.Read(array, 0, array.Length);
         array = Encry.DecryptDES(array, "C.I.t.ks");
         LicObj result = null;
         if (array != null)
         {
             using (MemoryStream memoryStream = new MemoryStream(array))
             {
                 memoryStream.Position = 0L;
                 BinaryFormatter binaryFormatter = new BinaryFormatter();
                 result = (binaryFormatter.Deserialize(memoryStream) as LicObj);
                 memoryStream.Close();
                 return(result);
             }
         }
         return(result);
     }
 }