Skip to content

devantler/dotnet-key-manager

Repository files navigation

🔓 .NET Key Manager

License Test codecov

A simple .NET library to manage cryptographic keys.

Show/hide folder structure
.
├── .github
│   └── workflows
├── Devantler.KeyManager.Core
│   └── Models
├── Devantler.KeyManager.Local.Age
└── Devantler.KeyManager.Local.Age.Tests
    └── LocalAgeKeyManagerTests

7 directories

Prerequisites

🚀 Getting Started

To get started, you can install the packages from NuGet.

# For the Age key model
dotnet add package Devantler.KeyManager.Local.Age

If you need to create a new implementation for a key manager, you can install the core package.

dotnet add package Devantler.Keys.Core

📝 Usage

Local Age Key Manager

The Local Age Key Manager is a simple key manager to manage Age keys on your local machine. The key manager saves and loads keys from your SOPS keyring by default.

Create a new key

To create a new key, you can use the CreateKeyAsync method.

using Devantler.KeyManager.Local.Age;

var keyManager = new LocalAgeKeyManager();

var key = await keyManager.CreateKeyAsync();

To delete a key, you can use the DeleteKeyAsync method.

using Devantler.Keys.Age;
using Devantler.KeyManager.Local.Age;

var keyManager = new LocalAgeKeyManager();

var ageKey = AgeKeygen.InMemory();
await keyManager.DeleteKeyAsync(ageKey);

Get an existing key

To get an existing key, you can use the GetKeyAsync method.

using Devantler.KeyManager.Local.Age;

var keyManager = new LocalAgeKeyManager();

var key = await keyManager.GetKeyAsync("<public key>");

Import a key

To import a key, you can use the ImportKeyAsync method.

using Devantler.Keys.Age;
using Devantler.KeyManager.Local.Age;

var keyManager = new LocalAgeKeyManager();

var ageKey = AgeKeygen.InMemory();

var key = await keyManager.ImportKeyAsync(ageKey);

Check if a key exists

To check if a key exists, you can use the KeyExistsAsync method.

using Devantler.KeyManager.Local.Age;

var keyManager = new LocalAgeKeyManager();

var exists = await keyManager.KeyExistsAsync("<public key>");

List all keys

To list all keys, you can use the ListKeysAsync method.

using Devantler.KeyManager.Local.Age;

var keyManager = new LocalAgeKeyManager();

var keys = await keyManager.ListKeysAsync();

About

A simple .NET library to manage SOPS secrets.

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Languages