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
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
using System;
using System.Text;
using System.Security.Cryptography;
using SafeCrypt.src.Helpers;
using SafeCrypt.src.Encryption.AesEncryption.Models;

namespace SafeCrypt
namespace SafeCrypt.src.Encrypt.AesEncryption
{
public class AesEncryption : BaseAesEncryption
{
Expand Down Expand Up @@ -116,12 +118,7 @@ private void NullChecks(string data, string secretKey)

if (secretKey == null || secretKey.Length <= 0)
throw new ArgumentNullException(nameof(secretKey));
}
}
}

public class AesEncryptionData
{
public byte[] Data { get; set; }
public byte[] Iv { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.IO;
using System.Security.Cryptography;

namespace SafeCrypt
namespace SafeCrypt.src.Encrypt.AesEncryption
{
public class BaseAesEncryption
{
Expand Down Expand Up @@ -56,10 +56,10 @@ public static byte[] DecryptAES(byte[] encryptedData, byte[] key, byte[] iv)
}
}

// Method to generate a random byte array of given length
// Used to get the IV
// Generate a random 16-byte IV for AES in CBC mode
public static byte[] GenerateRandomBytes(int length)
// Method to generate a random byte array of given length
// Used to get the IV
// Generate a random 16-byte IV for AES in CBC mode
public static byte[] GenerateRandomBytes(int length)
{
byte[] randomBytes = new byte[length];
using (RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider())
Expand Down
12 changes: 12 additions & 0 deletions src/Encryption/AesEncryption/Models/AesEncryptionData.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace SafeCrypt.src.Encryption.AesEncryption.Models
{
public class AesEncryptionData
{
public byte[] Data { get; set; }
public byte[] Iv { get; set; }
}
}
2 changes: 1 addition & 1 deletion Enums/ReturnType.cs → src/Enums/ReturnType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using System.Collections.Generic;
using System.Text;

namespace SafeCrypt
namespace SafeCrypt.src.Enums
{
public enum ReturnType
{
Expand Down
2 changes: 1 addition & 1 deletion Helpers/Converters.cs → src/Helpers/Converters.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.IO;
using System.Text;

namespace SafeCrypt
namespace SafeCrypt.src.Helpers
{
public static class Converters
{
Expand Down