Skip to content

Commit 79ab16f

Browse files
authored
Merge pull request #48 from selfmadecode/46-exception-thrown-when-using-the-encrypttohexstringasync
Exception thrown when using the EncryptToHexStringAsync encryption method
2 parents 03c71f7 + 3ba8acf commit 79ab16f

4 files changed

Lines changed: 17 additions & 18 deletions

File tree

src/SafeCrypt.Lib/Encryption/AesEncryption/Decrypting.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public async Task<DecryptionData> DecryptFromHexStringAsync(DecryptionParameters
3838
return responseData;
3939
}
4040
// Convert input string to bytes
41-
byte[] dataBytes = param.IV.ConvertKeysToBytes();
41+
byte[] dataBytes = param.IV.HexadecimalStringToByteArray();
4242

4343
// Validate block size based on AES algorithm's requirements
4444
if (!Validators.IsValidBlockSize(dataBytes.Length))
@@ -80,7 +80,7 @@ public async Task<DecryptionData> DecryptFromBase64StringAsync(DecryptionParamet
8080
var responseData = new DecryptionData();
8181

8282
Validators.ValidateNotNull(param);
83-
83+
8484

8585
if (!Validators.IsBase64String(param.SecretKey))
8686
{

src/SafeCrypt.Lib/Encryption/AesEncryption/Encrypting.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
2-
using System.Security.Cryptography;
3-
using System.Threading.Tasks;
4-
using SafeCrypt.AesEncryption;
1+
using SafeCrypt.AesEncryption;
52
using SafeCrypt.Helpers;
63
using SafeCrypt.Models;
4+
using System;
5+
using System.Security.Cryptography;
6+
using System.Threading.Tasks;
77

88
namespace SafeCrypt.AESEncryption
99
{
@@ -35,7 +35,7 @@ public async Task<EncryptionData> EncryptToHexStringAsync(EncryptionParameters p
3535
}
3636

3737
// Convert input string to bytes
38-
byte[] dataBytes = param.IV.ConvertKeysToBytes();
38+
byte[] dataBytes = param.IV.HexadecimalStringToByteArray();
3939

4040
// Validate block size based on AES algorithm's requirements
4141
if (!Validators.IsValidBlockSize(dataBytes.Length))
@@ -139,14 +139,14 @@ private void NullChecks(string data, string secretKey)
139139
if (data == null || data.Length <= 0)
140140
throw new ArgumentNullException(nameof(data));
141141

142-
if (secretKey == null )
142+
if (secretKey == null)
143143
throw new ArgumentNullException(nameof(secretKey));
144144
}
145145

146146
private void AddError(EncryptionData responseData, string error)
147147
{
148148
responseData.HasError = true;
149149
responseData.Errors.Add(error);
150-
}
150+
}
151151
}
152152
}

src/SafeCrypt.Lib/SafeCrypt.csproj

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,27 +15,26 @@
1515
<PackageReadmeFile>README.md</PackageReadmeFile>
1616
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
1717
<PackageLicenseFile>MitLicense.txt</PackageLicenseFile>
18-
<PackageReleaseNotes>SafeCrypt Library - Release Notes - Version 1.0.1
18+
<PackageReleaseNotes>SafeCrypt Library - Release Notes - Version 1.0.2
1919

20-
This release (version 1.0.1) includes updates to the documentation and namespace changes. We have improved the README document to provide more comprehensive information about the library and made adjustments to the namespaces for better organization.
20+
We are excited to announce the latest version of SafeCrypt (v1.0.2), featuring a significant enhancement to our encryption methods. In this release, all encryption operations are now asynchronous, providing improved performance and responsiveness.
2121

22-
Changes
23-
24-
- Updated README document with detailed usage instructions, API references, and contribution guidelines.
25-
- Made changes to namespaces for better organization and clarity in the codebase.
22+
What's New:
23+
Async Encryption and Decryption:
24+
We have made all encryption methods asynchronous to better align with modern programming practices and enhance the overall responsiveness of SafeCrypt.
2625

2726
Bug Fixes
2827

2928
No bug fixes in this release.
3029

3130
Upgrade Command:
32-
dotnet add package SafeCrypt --version 1.0.1
31+
dotnet add package SafeCrypt --version 1.0.2
3332

3433
Feedback and Contributions:
3534
We appreciate your feedback and contributions! If you encounter any issues or have suggestions, please create an issue on GitHub: https://github.com/selfmadecode/SafeCrypt/issues
3635

3736
Thank you for using the SafeCrypt Library!</PackageReleaseNotes>
38-
<Version>1.0.1</Version>
37+
<Version>1.0.2</Version>
3938
</PropertyGroup>
4039

4140
<ItemGroup>

src/SafeCrypt.Test/Program.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
var decryptionData = await decryptor.DecryptFromBase64StringAsync(decryptorParam);
3333

3434
Console.WriteLine("............Decryption Started............");
35-
Console.WriteLine($"Decrypted data: { decryptionData.DecryptedData }");
35+
Console.WriteLine($"Decrypted data: {decryptionData.DecryptedData}");
3636
Console.WriteLine($"IV key: {decryptionData.Iv}");
3737
Console.WriteLine($"Secret key: {decryptionData.SecretKey}");
3838

0 commit comments

Comments
 (0)