Beispiel #1
0
        private static UdpPacketSendFileRequestExtend ResolveSendFileRequestExtend(BinaryReader rdr, byte[] priKey)
        {
            int len = rdr.ReadInt32();

            byte[] buf = rdr.ReadBytes(len);

            byte[] deBuf = SecurityFactory.Decrypt(buf, priKey);

            using (MemoryStream ms = new MemoryStream(deBuf))
            {
                using (BinaryReader bw = new BinaryReader(ms))
                {
                    LanFile file = new LanFile();
                    file.Name     = bw.ReadString();
                    file.Length   = bw.ReadInt32();
                    file.IsFolder = bw.ReadBoolean();

                    bw.Close();
                    ms.Close();

                    UdpPacketSendFileRequestExtend extend = new UdpPacketSendFileRequestExtend();
                    extend.File = file;

                    return(extend);
                }
            }
        }
Beispiel #2
0
 public void EncDec()
 {
     var decComputer = SecurityFactory.Decrypt("NrMLgYbsQyz8MP55xEggqA==", "Ph0tomanagerK3y5Ph0tomanagerK3y5");
     //var decIris = SecurityFactory.Encrypt("abc12345!", "Ph0tomanagerK3y5Ph0tomanagerK3y5");
     //var decBellebos = SecurityFactory.Encrypt("Belleb0s!", "Ph0tomanagerK3y5Ph0tomanagerK3y5");
     //var encComputer = SecurityFactory.Decrypt("YQk2mQHq81aS92981nkZ8A==", "Ph0tomanagerK3y5Ph0tomanagerK3y5");
 }
        private static TcpPacketRequestFileTransportExtend ResolveRequestFileTransportExtend(BinaryReader rdr, byte[] priKey)
        {
            TcpPacketRequestFileTransportExtend extend = new TcpPacketRequestFileTransportExtend();
            int len = rdr.ReadInt32();

            byte[] buf = rdr.ReadBytes(len);

            byte[] deBuf = SecurityFactory.Decrypt(buf, priKey);
            extend.FileID = BitConverter.ToInt64(deBuf, 0);

            return(extend);
        }
Beispiel #4
0
        private static UdpPacketTextExtend ResolveTextExtend(BinaryReader rdr, byte[] priKey)
        {
            UdpPacketTextExtend extend = new UdpPacketTextExtend();
            int len = rdr.ReadInt32();

            byte[] buf = rdr.ReadBytes(len);

            byte[] deBuf = SecurityFactory.Decrypt(buf, priKey);
            extend.Text = Packet.ENCODING.GetString(deBuf);

            return(extend);
        }
Beispiel #5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var encMachineName = ConfigurationManager.AppSettings["MachineName"];
            var key            = ConfigurationManager.AppSettings["SecurityKey"];
            var machineName    = SecurityFactory.Decrypt(encMachineName, key);
            var fileName       = $@"{FolderFactory.SettingFolder}\{Environment.MachineName}.ini";

            if (!File.Exists(fileName))
            {
                MessageBox.Show("Photomanager kan niet worden geladen! Gelieve contact op te nemen met de administrator.", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }
            if (string.IsNullOrEmpty(machineName) || !machineName.Equals(Environment.MachineName))
            {
                MessageBox.Show($"Photomanager kan niet worden geladen! => machine: {Environment.MachineName}", "Fout", MessageBoxButton.OK, MessageBoxImage.Error);
                Environment.Exit(0);
            }
            var currentProcess = Process.GetCurrentProcess();

            if (!IsProcessRunning(currentProcess.ProcessName))
            {
                PhotomanagerFactory.CloseBusyLogs();
                ActivityLogFileName = $"Activity_{DateTime.Now:yyyyMMddHHmmss}_B";
                AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;

                if (IsAdHoc)
                {
                    var adhocStatusFile = NetworkFactory.GetAdHocFileName(Variables.AdHocStatusFile, ActivityLogFileName);
                    if (!NetworkFactory.IsCorrectSsid(adhocStatusFile, ConfigurationManager.AppSettings["AdHocSSID"]))
                    {
                        NetworkFactory.SetAdHocNetwork(ActivityLogFileName);
                    }
                    if (!NetworkFactory.IsStarted(adhocStatusFile))
                    {
                        NetworkFactory.StartAdHocNetwork(adhocStatusFile, ActivityLogFileName);
                    }
                }
                base.OnStartup(e);
            }
            else
            {
                if (Process.GetProcessesByName(currentProcess.ProcessName).Length > 1)
                {
                    MessageBox.Show("De applicatie is reeds gestart!", "Informatie", MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                    Current.Shutdown();
                }
            }
        }
Beispiel #6
0
        private static UdpPacketImageExtend ResolveImageExtend(BinaryReader rdr, byte[] priKey)
        {
            UdpPacketImageExtend extend = new UdpPacketImageExtend();
            int len = rdr.ReadInt32();

            byte[] buf = rdr.ReadBytes(len);

            byte[] deBuf = SecurityFactory.Decrypt(buf, priKey);

            using (MemoryStream ms = new MemoryStream(deBuf))
            {
                Image image = Image.FromStream(ms);
                extend.Image = image;
            }
            return(extend);
        }
Beispiel #7
0
        private bool ContainsValidMachine(string machineName)
        {
            if (IsTesting)
            {
                return(true);
            }

            if (machineName.Contains("-_-"))
            {
                foreach (var s in machineName.Split(new[] { "-_-" }, StringSplitOptions.None).ToArray())
                {
                    if (SecurityFactory.Decrypt(s, SecurityKey).Equals(MachineName))
                    {
                        return(true);
                    }
                }
            }
            else if (SecurityFactory.Decrypt(machineName, SecurityKey).Equals(MachineName))
            {
                return(true);
            }
            return(false);
        }
Beispiel #8
0
 private void btnDecrypt_Click(object sender, EventArgs e)
 {
     txtDecryptedValue.Text = !string.IsNullOrEmpty(txtValueToDecrypt.Text) ? SecurityFactory.Decrypt(txtValueToDecrypt.Text, ConfigurationManager.AppSettings["SecurityKey"]) : string.Empty;
 }
Beispiel #9
0
 public string Decrypt(string value)
 {
     return(SecurityFactory.Decrypt(value, SecurityKey));
 }