Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/SafeCrypt.Lib/Encryption/AesEncryption/Decrypting.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public async Task<DecryptionData> DecryptFromHexStringAsync(DecryptionParameters
return responseData;
}
// Convert input string to bytes
byte[] dataBytes = param.IV.ConvertKeysToBytes();
byte[] dataBytes = param.IV.HexadecimalStringToByteArray();

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

Validators.ValidateNotNull(param);


if (!Validators.IsBase64String(param.SecretKey))
{
Expand Down
14 changes: 7 additions & 7 deletions src/SafeCrypt.Lib/Encryption/AesEncryption/Encrypting.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
using System;
using System.Security.Cryptography;
using System.Threading.Tasks;
using SafeCrypt.AesEncryption;
using SafeCrypt.AesEncryption;
using SafeCrypt.Helpers;
using SafeCrypt.Models;
using System;
using System.Security.Cryptography;
using System.Threading.Tasks;

namespace SafeCrypt.AESEncryption
{
Expand Down Expand Up @@ -35,7 +35,7 @@ public async Task<EncryptionData> EncryptToHexStringAsync(EncryptionParameters p
}

// Convert input string to bytes
byte[] dataBytes = param.IV.ConvertKeysToBytes();
byte[] dataBytes = param.IV.HexadecimalStringToByteArray();

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

if (secretKey == null )
if (secretKey == null)
throw new ArgumentNullException(nameof(secretKey));
}

private void AddError(EncryptionData responseData, string error)
{
responseData.HasError = true;
responseData.Errors.Add(error);
}
}
}
}
2 changes: 1 addition & 1 deletion src/SafeCrypt.Test/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
var decryptionData = await decryptor.DecryptFromBase64StringAsync(decryptorParam);

Console.WriteLine("............Decryption Started............");
Console.WriteLine($"Decrypted data: { decryptionData.DecryptedData }");
Console.WriteLine($"Decrypted data: {decryptionData.DecryptedData}");
Console.WriteLine($"IV key: {decryptionData.Iv}");
Console.WriteLine($"Secret key: {decryptionData.SecretKey}");

Expand Down