Skip to content

IsValidKey Method ​

Definition ​

  • Namespace: JASE.Crypto
  • Assembly: JASE.Crypto.dll

Overloads ​

NameDescription
bool IsValidKey(byte[] key, SymmetricAlgorithms algorithm = null)Determines whether the supplied binary key material meets the legal key-size requirements for the specified symmetric encryption algorithm.
bool IsValidKey(string key, SymmetricAlgorithms algorithm = null)Determines whether the specified key string represents a valid key for the selected symmetric encryption algorithm.

bool IsValidKey(byte[] key, SymmetricAlgorithms algorithm = null) ​

csharp
bool IsValidKey(byte[] key, SymmetricAlgorithms algorithm = null)

Determines whether the supplied binary key material meets the legal key-size requirements for the specified symmetric encryption algorithm.

Parameters ​

NameDescription
algorithmThe symmetric algorithm whose permitted key sizes should be validated. Defaults to AES256.
keyThe key material as a byte array. If , the method returns .

Returns ​

if the key length (in bits) falls within the algorithm’s allowed size range and aligns with the required skip increments; otherwise .

bool IsValidKey(string key, SymmetricAlgorithms algorithm = null) ​

csharp
bool IsValidKey(string key, SymmetricAlgorithms algorithm = null)

Determines whether the specified key string represents a valid key for the selected symmetric encryption algorithm.

Parameters ​

NameDescription
algorithmThe symmetric algorithm whose key-size requirements should be validated. Defaults to AES256.
keyThe key material as a text string. The string is converted to bytes using Encoding rules via ToByteArray().

Returns ​

if the encoded byte representation of key satisfies the legal key sizes for the specified algorithm; otherwise .