Skip to content

Commit 16f2c78

Browse files
committed
feat: add IsValidBlockSize and IsValidByteArray method
1 parent ee7c770 commit 16f2c78

1 file changed

Lines changed: 24 additions & 0 deletions

File tree

src/Helpers/Validators.cs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,29 @@ public static bool IsBase64String(string keyAsString)
8383
return false;
8484
}
8585
}
86+
87+
/// <summary>
88+
/// Validates whether the block size is valid for the AES algorithm.
89+
/// </summary>
90+
/// <param name="dataLength">The length of the data to be encrypted.</param>
91+
/// <returns>True if the block size is valid; otherwise, false.</returns>
92+
public static bool IsValidBlockSize(int dataLength)
93+
{
94+
// AES block size is 128 bits (16 bytes)
95+
return dataLength % 16 == 0;
96+
}
97+
98+
/// <summary>
99+
/// Validates whether the byte array is valid for a specific algorithm.
100+
/// </summary>
101+
/// <param name="byteArray">The byte array to validate.</param>
102+
/// <returns>True if the byte array is valid; otherwise, false.</returns>
103+
private static bool IsValidByteArray(byte[] byteArray)
104+
{
105+
// Add your specific validation criteria here
106+
// For example, you might check for non-null, non-empty, or other constraints
107+
108+
return byteArray != null && byteArray.Length > 0;
109+
}
86110
}
87111
}

0 commit comments

Comments
 (0)