Skip to content

Commit 3539667

Browse files
author
Dominic Beger
committed
Merge branch 'release/v3.3'
2 parents 28d5d2e + 3d3f5bf commit 3539667

File tree

165 files changed

+5418
-5311
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+5418
-5311
lines changed

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
# nUpdate - .NET Update Solution
44

5-
[![Release](https://img.shields.io/badge/release-v3.2.1-blue.svg)](https://github.com/ProgTrade/nUpdate/releases)
6-
[![NuGet](https://img.shields.io/badge/nuget%20nUpdate.ProvideTAP-v3.2.1-red.svg)](https://www.nuget.org/packages/nUpdate.ProvideTAP/)
7-
[![NuGet](https://img.shields.io/badge/nuget%20nUpdate.WithoutTAP-v3.2.1-red.svg)](https://www.nuget.org/packages/nUpdate.WithoutTAP/)
5+
[![Release](https://img.shields.io/badge/release-v3.3-blue.svg)](https://github.com/ProgTrade/nUpdate/releases)
6+
[![NuGet](https://img.shields.io/badge/nuget%20nUpdate.ProvideTAP-v3.3-red.svg)](https://www.nuget.org/packages/nUpdate.ProvideTAP/)
7+
[![NuGet](https://img.shields.io/badge/nuget%20nUpdate.WithoutTAP-v3.3-red.svg)](https://www.nuget.org/packages/nUpdate.WithoutTAP/)
88
[![Issues](https://img.shields.io/github/issues/ProgTrade/nUpdate.svg)](https://github.com/ProgTrade/nUpdate/issues)
99
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/ProgTrade/nUpdate/master/LICENSE)
1010
[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=dominic%2ebeger%40hotmail%2ede&lc=DE&item_name=nUpdate&no_note=0&currency_code=EUR&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHostedGuest)
@@ -41,7 +41,7 @@ You can get the necessary libraries and applications from the current [releases]
4141
If you want to use nUpdate with the Taskbased Asynchronous Pattern including `async` and `await`, then install this package:
4242

4343
```
44-
PM> Install-Package nUpdate.ProvideTAP -Version 3.2.1
44+
PM> Install-Package nUpdate.ProvideTAP -Version 3.3.0
4545
```
4646

4747
##### Trouble installing nUpdate.ProvideTAP?
@@ -53,7 +53,7 @@ It may be that Visual Studio shows you a warning like `The primary reference "nU
5353
Otherwise, if you want to use the Eventbased Asynchronous Pattern, make sure to install this package:
5454

5555
```
56-
PM> Install-Package nUpdate.WithoutTAP -Version 3.2.1
56+
PM> Install-Package nUpdate.WithoutTAP -Version 3.3.0
5757
```
5858

5959
## Web
Lines changed: 46 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Author: Dominic Beger (Trade/ProgTrade) 2016
1+
// Copyright © Dominic Beger 2018
22

33
using System;
44
using System.IO;
@@ -10,16 +10,16 @@ namespace nUpdate.Administration.Core
1010
public class AesManager
1111
{
1212
/// <summary>
13-
/// Encrypts a string with the given key and initializing vector.
13+
/// Decrypts a string with the given key and initializing vector.
1414
/// </summary>
15-
/// <param name="plainText">The text to encrypt.</param>
16-
/// <param name="keyPassword">The password which the key should be derived from.</param>
17-
/// <param name="ivPassword">The password which the initializing vector should be drived from.</param>
18-
/// <returns>Returns the encrypted string as a byte-array.</returns>
19-
public static byte[] Encrypt(string plainText, string keyPassword, string ivPassword)
15+
/// <param name="cipherText">The byte-array of the encrypted string.</param>
16+
/// <param name="keyPassword">The key to use.</param>
17+
/// <param name="ivPassword">The initializing vector to use.</param>
18+
/// <returns>Returns the plain string as SecureString.</returns>
19+
public static SecureString Decrypt(byte[] cipherText, string keyPassword, string ivPassword)
2020
{
21-
if (string.IsNullOrEmpty(plainText))
22-
throw new ArgumentNullException(nameof(plainText));
21+
if (cipherText == null || cipherText.Length <= 0)
22+
throw new ArgumentNullException(nameof(cipherText));
2323
if (keyPassword == null || keyPassword.Length <= 0)
2424
throw new ArgumentNullException(nameof(keyPassword));
2525
if (ivPassword == null || ivPassword.Length <= 0)
@@ -29,47 +29,49 @@ public static byte[] Encrypt(string plainText, string keyPassword, string ivPass
2929
new byte[] {0x43, 0x87, 0x23, 0x72, 0x45, 0x56, 0x68, 0x14, 0x62, 0x84});
3030
var ivPasswordDeriveBytes = new Rfc2898DeriveBytes(ivPassword,
3131
new byte[] {0x43, 0x87, 0x23, 0x72, 0x45, 0x56, 0x68, 0x14, 0x62, 0x84});
32-
byte[] encrypted;
3332

33+
string plaintext;
3434
using (var aesAlg = new AesManaged())
3535
{
3636
aesAlg.KeySize = 256;
37-
aesAlg.Key = keyPasswordDeriveBytes.GetBytes(aesAlg.KeySize/8);
38-
aesAlg.IV = ivPasswordDeriveBytes.GetBytes(aesAlg.BlockSize/8);
37+
aesAlg.Key = keyPasswordDeriveBytes.GetBytes(aesAlg.KeySize / 8);
38+
aesAlg.IV = ivPasswordDeriveBytes.GetBytes(aesAlg.BlockSize / 8);
3939

4040
// Create a decrytor to perform the stream transform.
41-
var encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
41+
var decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
4242

43-
// Create the streams used for encryption.
44-
using (var msEncrypt = new MemoryStream())
43+
// Create the streams used for decryption.
44+
using (var msDecrypt = new MemoryStream(cipherText))
4545
{
46-
using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
46+
using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
4747
{
48-
using (var swEncrypt = new StreamWriter(csEncrypt))
48+
using (var srDecrypt = new StreamReader(csDecrypt))
4949
{
50-
//Write all data to the stream.
51-
swEncrypt.Write(plainText);
50+
// Read the decrypted bytes from the decrypting stream
51+
// and place them in a string.
52+
plaintext = srDecrypt.ReadToEnd();
5253
}
53-
encrypted = msEncrypt.ToArray();
5454
}
5555
}
5656
}
5757

58-
// Return the encrypted bytes from the memory stream.
59-
return encrypted;
58+
var securedPlainText = new SecureString();
59+
foreach (var c in plaintext)
60+
securedPlainText.AppendChar(c);
61+
return securedPlainText;
6062
}
6163

6264
/// <summary>
63-
/// Decrypts a string with the given key and initializing vector.
65+
/// Encrypts a string with the given key and initializing vector.
6466
/// </summary>
65-
/// <param name="cipherText">The byte-array of the encrypted string.</param>
66-
/// <param name="keyPassword">The key to use.</param>
67-
/// <param name="ivPassword">The initializing vector to use.</param>
68-
/// <returns>Returns the plain string as SecureString.</returns>
69-
public static SecureString Decrypt(byte[] cipherText, string keyPassword, string ivPassword)
67+
/// <param name="plainText">The text to encrypt.</param>
68+
/// <param name="keyPassword">The password which the key should be derived from.</param>
69+
/// <param name="ivPassword">The password which the initializing vector should be drived from.</param>
70+
/// <returns>Returns the encrypted string as a byte-array.</returns>
71+
public static byte[] Encrypt(string plainText, string keyPassword, string ivPassword)
7072
{
71-
if (cipherText == null || cipherText.Length <= 0)
72-
throw new ArgumentNullException(nameof(cipherText));
73+
if (string.IsNullOrEmpty(plainText))
74+
throw new ArgumentNullException(nameof(plainText));
7375
if (keyPassword == null || keyPassword.Length <= 0)
7476
throw new ArgumentNullException(nameof(keyPassword));
7577
if (ivPassword == null || ivPassword.Length <= 0)
@@ -79,36 +81,35 @@ public static SecureString Decrypt(byte[] cipherText, string keyPassword, string
7981
new byte[] {0x43, 0x87, 0x23, 0x72, 0x45, 0x56, 0x68, 0x14, 0x62, 0x84});
8082
var ivPasswordDeriveBytes = new Rfc2898DeriveBytes(ivPassword,
8183
new byte[] {0x43, 0x87, 0x23, 0x72, 0x45, 0x56, 0x68, 0x14, 0x62, 0x84});
84+
byte[] encrypted;
8285

83-
string plaintext;
8486
using (var aesAlg = new AesManaged())
8587
{
8688
aesAlg.KeySize = 256;
87-
aesAlg.Key = keyPasswordDeriveBytes.GetBytes(aesAlg.KeySize/8);
88-
aesAlg.IV = ivPasswordDeriveBytes.GetBytes(aesAlg.BlockSize/8);
89+
aesAlg.Key = keyPasswordDeriveBytes.GetBytes(aesAlg.KeySize / 8);
90+
aesAlg.IV = ivPasswordDeriveBytes.GetBytes(aesAlg.BlockSize / 8);
8991

9092
// Create a decrytor to perform the stream transform.
91-
var decryptor = aesAlg.CreateDecryptor(aesAlg.Key, aesAlg.IV);
93+
var encryptor = aesAlg.CreateEncryptor(aesAlg.Key, aesAlg.IV);
9294

93-
// Create the streams used for decryption.
94-
using (var msDecrypt = new MemoryStream(cipherText))
95+
// Create the streams used for encryption.
96+
using (var msEncrypt = new MemoryStream())
9597
{
96-
using (var csDecrypt = new CryptoStream(msDecrypt, decryptor, CryptoStreamMode.Read))
98+
using (var csEncrypt = new CryptoStream(msEncrypt, encryptor, CryptoStreamMode.Write))
9799
{
98-
using (var srDecrypt = new StreamReader(csDecrypt))
100+
using (var swEncrypt = new StreamWriter(csEncrypt))
99101
{
100-
// Read the decrypted bytes from the decrypting stream
101-
// and place them in a string.
102-
plaintext = srDecrypt.ReadToEnd();
102+
//Write all data to the stream.
103+
swEncrypt.Write(plainText);
103104
}
105+
106+
encrypted = msEncrypt.ToArray();
104107
}
105108
}
106109
}
107110

108-
var securedPlainText = new SecureString();
109-
foreach (var c in plaintext)
110-
securedPlainText.AppendChar(c);
111-
return securedPlainText;
111+
// Return the encrypted bytes from the memory stream.
112+
return encrypted;
112113
}
113114
}
114115
}

nUpdate.Administration/Core/Application/Extension/AssociationManager.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Author: Dominic Beger (Trade/ProgTrade) 2016
1+
// Copyright © Dominic Beger 2018
22

33
using System.Collections.Generic;
44

@@ -9,27 +9,6 @@ namespace nUpdate.Administration.Core.Application.Extension
99
/// </summary>
1010
public class AssociationManager
1111
{
12-
/// <summary>
13-
/// Determines of the list of extensions are associated with the specified program id.
14-
/// </summary>
15-
/// <param name="progId">Program id to check against.</param>
16-
/// <param name="extensions">String array of extensions to check against the program id.</param>
17-
/// <returns>String array of extensions that were not associated with the program id.</returns>
18-
public string[] CheckAssociation(string progId, params string[] extensions)
19-
{
20-
var notAssociated = new List<string>();
21-
22-
foreach (var s in extensions)
23-
{
24-
var fai = new FileAssociationInfo(s);
25-
26-
if (!fai.Exists || fai.ProgId != progId)
27-
notAssociated.Add(s);
28-
}
29-
30-
return notAssociated.ToArray();
31-
}
32-
3312
/// <summary>
3413
/// Associates a single executable with a list of extensions.
3514
/// </summary>
@@ -78,5 +57,26 @@ public void Associate(string progId, params string[] extensions)
7857
fai.ProgId = progId;
7958
}
8059
}
60+
61+
/// <summary>
62+
/// Determines of the list of extensions are associated with the specified program id.
63+
/// </summary>
64+
/// <param name="progId">Program id to check against.</param>
65+
/// <param name="extensions">String array of extensions to check against the program id.</param>
66+
/// <returns>String array of extensions that were not associated with the program id.</returns>
67+
public string[] CheckAssociation(string progId, params string[] extensions)
68+
{
69+
var notAssociated = new List<string>();
70+
71+
foreach (var s in extensions)
72+
{
73+
var fai = new FileAssociationInfo(s);
74+
75+
if (!fai.Exists || fai.ProgId != progId)
76+
notAssociated.Add(s);
77+
}
78+
79+
return notAssociated.ToArray();
80+
}
8181
}
8282
}

0 commit comments

Comments
 (0)