using System;
-using System.IO;
using System.Security.Cryptography;
using System.Text;
{
public static class Cryptography
{
- private static string KEY = "8E16A57381AFDA47856682CEBE85DCF5982F59321AE28B2822C1C9E1FC481C50";
- private static string IV = "7CD37E78623793D4C4BB81DB73B08522";
+ private static string GetKeyFromContainer()
+ {
+ // store key in keycontainer, this generates a new key if none exist
+ CspParameters cp = new CspParameters();
+ cp.KeyContainerName = "SpeedportHybridControl";
+ RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(cp);
+ return rsa.ToXmlString(true);
+ }
public static string Encrypt(string clearText)
{
+ RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048);
byte[] clearBytes = Encoding.Unicode.GetBytes(clearText);
- string result;
- using (Aes encryptor = Aes.Create())
- {
- if (Object.Equals(encryptor, null))
- {
- result = null;
- return result;
- }
+ rsa.FromXmlString(GetKeyFromContainer());
+ string result = Convert.ToBase64String(rsa.Encrypt(clearBytes, true));
+ rsa.Dispose();
- encryptor.KeySize = 256;
- encryptor.BlockSize = 128;
- encryptor.Mode = CipherMode.CBC;
- encryptor.Padding = PaddingMode.PKCS7;
- encryptor.Key = util.HexToByte(KEY);
- encryptor.IV = util.HexToByte(IV);
-
- using (MemoryStream ms = new MemoryStream())
- {
- using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
- {
- cs.Write(clearBytes, 0, clearBytes.Length);
- cs.Close();
- }
- clearText = Convert.ToBase64String(ms.ToArray());
- }
- }
- result = clearText;
return result;
}
public static string Decrypt(string cipherText)
{
+ RSACryptoServiceProvider rsa = new RSACryptoServiceProvider(2048);
byte[] cipherBytes = Convert.FromBase64String(cipherText);
- string result;
- using (Aes encryptor = Aes.Create())
- {
- if (Object.Equals(encryptor, null))
- {
- result = null;
- return result;
- }
-
- encryptor.KeySize = 256;
- encryptor.BlockSize = 128;
- encryptor.Mode = CipherMode.CBC;
- encryptor.Padding = PaddingMode.PKCS7;
- encryptor.Key = util.HexToByte(KEY);
- encryptor.IV = util.HexToByte(IV);
+ rsa.FromXmlString(GetKeyFromContainer());
+ string result = Encoding.Unicode.GetString(rsa.Decrypt(cipherBytes, true));
+ rsa.Dispose();
- using (MemoryStream ms = new MemoryStream())
- {
- using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateDecryptor(), CryptoStreamMode.Write))
- {
- cs.Write(cipherBytes, 0, cipherBytes.Length);
- cs.Close();
- }
- cipherText = Encoding.Unicode.GetString(ms.ToArray());
- }
- }
- result = cipherText;
return result;
}
}
//2016-09-01 17:15:20: LTE-ZellInfo: PLMN = 26201, CellID = 25721859, Band = LTE1800, RSRP = -90dBm, RSRQ = -8dB (LT004)
//01.09.2016 19:44:48: Funkzellen Info: 26201,34701569,3,-96,-11 (LT004)
LteInfoModel lte = Application.Current.FindResource("LteInfoModel") as LteInfoModel;
+
+ parts = line.Split(',');
+ string frequenz = parts[2];
+
if (line.Contains("Band = LTE"))
{
- parts = line.Split(',');
- string frequenz = parts[2];
lte.frequenz = string.Concat(frequenz.Substring(10, frequenz.Length - 10), " MHz");
}
else
{
- parts = line.Split(',');
- string frequenz = parts[2];
-
if (frequenz.Equals("20"))
{
frequenz = "800 MHz";
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl.page"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="AboutPage">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="ControlsPage">
xmlns:local="clr-namespace:SpeedportHybridControl.page"
xmlns:d3="http://research.microsoft.com/DynamicDataDisplay/1.0"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="DslPage">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="InterfacePage">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="LanPage">
xmlns:local="clr-namespace:SpeedportHybridControl"
xmlns:Implementations="clr-namespace:SpeedportHybridControl.Implementations;assembly=SpeedportHybridControl.Implementations"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="LoginPage">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="LteInfoPage">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="OverviewPage">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="PhonePage">
<Grid DataContext="{StaticResource PhonePageModel}">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="StatusPage">
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:SpeedportHybridControl"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="SyslogPage">
<Grid DataContext="{StaticResource SyslogPageModel}">
xmlns:local="clr-namespace:SpeedportHybridControl"
xmlns:Implementations="clr-namespace:SpeedportHybridControl.Implementations;assembly=SpeedportHybridControl.Implementations"
mc:Ignorable="d"
+ d:DesignWidth="514" d:DesignHeight="287"
Width="Auto" Height="Auto"
Title="TR181Page">