Skip to content

Commit

Permalink
Network/Security: AES key generation
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcidev committed May 22, 2015
1 parent 9176238 commit 9091eaf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
11 changes: 8 additions & 3 deletions Client/Security/AesEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ public static class AesEncryptor
{
private static Aes aes;
private static byte[] ivec = { 255, 254, 253, 252, 251, 250, 249, 248, 60, 61, 62, 63, 64, 65, 66, 67 };
private static byte[] key = new byte[16];

public static string Key { get; private set; }
public static byte[] Key { get { return key; } }

// Incializes AES instance
public static void Inicialize()
Expand All @@ -22,9 +23,13 @@ public static void Inicialize()
aes.Clear();

aes = Aes.Create();
using (var rng = new RNGCryptoServiceProvider())
{
rng.GetBytes(key);
}

aes.IV = ivec;
Key = "yayayaIamLordeya";
aes.Key = System.Text.Encoding.ASCII.GetBytes(Key);
aes.Key = key;
aes.Padding = PaddingMode.Zeros;
}

Expand Down
4 changes: 2 additions & 2 deletions Client/Security/RsaEncryptor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ public static void Inicialize()
}

// Encrypts data
public static byte[] Encrypt(string toEncrypt)
public static byte[] Encrypt(byte[] toEncrypt)
{
if (rsa == null)
return null;

return rsa.Encrypt(System.Text.Encoding.ASCII.GetBytes(toEncrypt), false);
return rsa.Encrypt(toEncrypt, false);
}

// Clears allocated resources
Expand Down

0 comments on commit 9091eaf

Please sign in to comment.