Пример #1
0
        static byte[] ZipEncrypt(LocalEvent e, string secretKey)
        {
            var bytes      = Encoding.UTF8.GetBytes(e.Json());
            var compressed = bytes.Compress();
            var encrypted  = BytesCrypto.EncryptFromBytes(secretKey, compressed);

            return(encrypted);
        }
Пример #2
0
 public LocalEvent GetEvent(string secretKey)
 {
     if (_event == null)
     {
         var decrypted    = BytesCrypto.DecryptToBytes(secretKey, ZipEncryptedData);
         var decompressed = decrypted.Decompress();
         var json         = Encoding.UTF8.GetString(decompressed);
         _event = (LocalEvent)json.Parse(AssemblyQualifiedName);
     }
     return(_event);
 }
Пример #3
0
 public static ZipEncryptedEvent For(LocalEvent e, string secretKey)
 => new ZipEncryptedEvent(ZipEncrypt(e, secretKey), e.GetType().AssemblyQualifiedName);