#### [Abblix\.Jwt](https://www.abblix.com/en/docs/api/abblix-jwt 'index')
### [Abblix\.Jwt](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt 'Abblix\.Jwt')

## JsonWebKeyFactory Class

A factory for creating JsonWebKey objects for various cryptographic key types\.
Supports RSA, Elliptic Curve, and symmetric \(HMAC\) keys for JWT operations\.

```csharp
public static class JsonWebKeyFactory
```

Inheritance [System\.Object](https://learn.microsoft.com/en-us/dotnet/api/system.object 'System\.Object') → JsonWebKeyFactory
### Methods

## JsonWebKeyFactory\.CreateEllipticCurve\(string, string\) Method {#Abblix.Jwt.JsonWebKeyFactory.CreateEllipticCurve(string,string)}

Creates an Elliptic Curve JsonWebKey with a specified curve\.

```csharp
public static Abblix.Jwt.EllipticCurveJsonWebKey CreateEllipticCurve(string curve, string algorithm);
```
#### Parameters

###### `curve` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.JsonWebKeyFactory.CreateEllipticCurve(string,string).curve}

The elliptic curve to use\. Common values: P\-256, P\-384, P\-521\.

###### `algorithm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.JsonWebKeyFactory.CreateEllipticCurve(string,string).algorithm}

The signing algorithm\. Common values: ES256, ES384, ES512\.

#### Returns
[EllipticCurveJsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.EllipticCurveJsonWebKey 'Abblix\.Jwt\.EllipticCurveJsonWebKey')  
A [EllipticCurveJsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.EllipticCurveJsonWebKey 'Abblix\.Jwt\.EllipticCurveJsonWebKey') suitable for ECDSA signing operations\.

## JsonWebKeyFactory\.CreateHmac\(string, Nullable\<int\>\) Method {#Abblix.Jwt.JsonWebKeyFactory.CreateHmac(string,System.Nullable_int_)}

Creates a symmetric \(Octet\) JsonWebKey for HMAC signing\.

```csharp
public static Abblix.Jwt.OctetJsonWebKey CreateHmac(string algorithm, System.Nullable<int> keySize=null);
```
#### Parameters

###### `algorithm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.JsonWebKeyFactory.CreateHmac(string,System.Nullable_int_).algorithm}

The HMAC algorithm\. Common values: HS256, HS384, HS512\.

###### `keySize` [System\.Nullable&lt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1')[System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32')[&gt;](https://learn.microsoft.com/en-us/dotnet/api/system.nullable-1 'System\.Nullable\`1') {#Abblix.Jwt.JsonWebKeyFactory.CreateHmac(string,System.Nullable_int_).keySize}

The key size in bytes\. Defaults based on algorithm: HS256=32, HS384=48, HS512=64\.

#### Returns
[OctetJsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.OctetJsonWebKey 'Abblix\.Jwt\.OctetJsonWebKey')  
A [OctetJsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.OctetJsonWebKey 'Abblix\.Jwt\.OctetJsonWebKey') suitable for HMAC signing operations\.

## JsonWebKeyFactory\.CreateRsa\(string, string, int\) Method {#Abblix.Jwt.JsonWebKeyFactory.CreateRsa(string,string,int)}

Creates an RSA JsonWebKey with a specified algorithm\.

```csharp
public static Abblix.Jwt.RsaJsonWebKey CreateRsa(string usage, string? algorithm=null, int keySize=2048);
```
#### Parameters

###### `usage` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.JsonWebKeyFactory.CreateRsa(string,string,int).usage}

The intended usage of the key, typically 'sig' for signing or 'enc' for encryption\.

###### `algorithm` [System\.String](https://learn.microsoft.com/en-us/dotnet/api/system.string 'System\.String') {#Abblix.Jwt.JsonWebKeyFactory.CreateRsa(string,string,int).algorithm}

The signing or encryption algorithm\. Key size is determined automatically based on the algorithm\.

###### `keySize` [System\.Int32](https://learn.microsoft.com/en-us/dotnet/api/system.int32 'System\.Int32') {#Abblix.Jwt.JsonWebKeyFactory.CreateRsa(string,string,int).keySize}

The size of the RSA key in bits\. If null, determined by algorithm \(defaults to 2048\)\.

#### Returns
[RsaJsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.RsaJsonWebKey 'Abblix\.Jwt\.RsaJsonWebKey')  
A [RsaJsonWebKey](https://www.abblix.com/en/docs/api/abblix-jwt/Abblix.Jwt.RsaJsonWebKey 'Abblix\.Jwt\.RsaJsonWebKey') configured for the specified algorithm\.
