---
title: "PublicKey"
description: "Namespace: Lacuna.Pki"
canonical: "https://docs.lacunasoftware.com/api/Lacuna.Pki/PublicKey"
locale: "pt-BR"
product: "PKI SDK"
last_updated: "2026-06-02"
---

# PublicKey

**Namespace:** `Lacuna.Pki`  
**Assembly:** `Lacuna.Pki`  
_Class_

```csharp
public abstract class PublicKey
```

**Hierarquia:** [`object`](https://learn.microsoft.com/dotnet/api/system.object) → `PublicKey`

## Propriedades

### `Algorithm`

```csharp
public abstract PKAlgorithm Algorithm { get; }
```

**Retorno**

[`PKAlgorithm`](https://docs.lacunasoftware.com/api/Lacuna.Pki/PKAlgorithm)

---

### `KeySize`

```csharp
public abstract int KeySize { get; }
```

**Retorno**

[`int`](https://learn.microsoft.com/dotnet/api/system.int32)

---

## Métodos

### `Decode(byte[])`

```csharp
public static PublicKey Decode(byte[] content)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `content` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) |  |

**Retorno**

[`PublicKey`](https://docs.lacunasoftware.com/api/Lacuna.Pki/PublicKey)

---

### `Decode(string)`

```csharp
public static PublicKey Decode(string pem)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `pem` | [`string`](https://learn.microsoft.com/dotnet/api/system.string) |  |

**Retorno**

[`PublicKey`](https://docs.lacunasoftware.com/api/Lacuna.Pki/PublicKey)

---

### `GetEncodedValue()`

Returns the DER encoding of the X.509 structure SubjectPublicKeyInfo

```csharp
public byte[] GetEncodedValue()
```

**Retorno**

[`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte)

---

### `GetEncryptionCsp()`

```csharp
public IEncryptionCsp GetEncryptionCsp()
```

**Retorno**

[`IEncryptionCsp`](https://docs.lacunasoftware.com/api/Lacuna.Pki/IEncryptionCsp)

---

### `GetInstance(AsymmetricAlgorithm)`

```csharp
public static PublicKey GetInstance(AsymmetricAlgorithm csp)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `csp` | [`AsymmetricAlgorithm`](https://learn.microsoft.com/dotnet/api/system.security.cryptography.asymmetricalgorithm) |  |

**Retorno**

[`PublicKey`](https://docs.lacunasoftware.com/api/Lacuna.Pki/PublicKey)

---

### `GetPemEncoded()`

Returns the PEM encoding of the public key

```csharp
public string GetPemEncoded()
```

**Retorno**

[`string`](https://learn.microsoft.com/dotnet/api/system.string)

---

### `GetSignatureCsp(DigestAlgorithm)`

```csharp
public ISignatureCsp GetSignatureCsp(DigestAlgorithm digestAlgorithm)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `digestAlgorithm` | [`DigestAlgorithm`](https://docs.lacunasoftware.com/api/Lacuna.Pki/DigestAlgorithm) |  |

**Retorno**

[`ISignatureCsp`](https://docs.lacunasoftware.com/api/Lacuna.Pki/ISignatureCsp)

---

### `IsEquivalent(PublicKey)`

```csharp
public bool IsEquivalent(PublicKey other)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `other` | [`PublicKey`](https://docs.lacunasoftware.com/api/Lacuna.Pki/PublicKey) |  |

**Retorno**

[`bool`](https://learn.microsoft.com/dotnet/api/system.boolean)

---

### `VerifyData(DigestAlgorithm, byte[], byte[])`

```csharp
public bool VerifyData(DigestAlgorithm digestAlgorithm, byte[] dataSigned, byte[] signature)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `digestAlgorithm` | [`DigestAlgorithm`](https://docs.lacunasoftware.com/api/Lacuna.Pki/DigestAlgorithm) |  |
| `dataSigned` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) |  |
| `signature` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) |  |

**Retorno**

[`bool`](https://learn.microsoft.com/dotnet/api/system.boolean)

---

### `VerifyHash(DigestAlgorithm, byte[], byte[])`

```csharp
public bool VerifyHash(DigestAlgorithm digestAlgorithm, byte[] hashSigned, byte[] signature)
```

**Parâmetros**

| Nome | Tipo | Descrição |
|---|---|---|
| `digestAlgorithm` | [`DigestAlgorithm`](https://docs.lacunasoftware.com/api/Lacuna.Pki/DigestAlgorithm) |  |
| `hashSigned` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) |  |
| `signature` | [`byte[]`](https://learn.microsoft.com/dotnet/api/system.byte) |  |

**Retorno**

[`bool`](https://learn.microsoft.com/dotnet/api/system.boolean)

---

## Membros herdados

[`ToString()`](https://learn.microsoft.com/dotnet/api/system.object.tostring), [`Equals(object)`](<https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object)>), [`Equals(object, object)`](<https://learn.microsoft.com/dotnet/api/system.object.equals#system-object-equals(system-object-system-object)>), [`ReferenceEquals(object, object)`](https://learn.microsoft.com/dotnet/api/system.object.referenceequals), [`GetHashCode()`](https://learn.microsoft.com/dotnet/api/system.object.gethashcode), [`GetType()`](https://learn.microsoft.com/dotnet/api/system.object.gettype), [`MemberwiseClone()`](https://learn.microsoft.com/dotnet/api/system.object.memberwiseclone)
